Теперь всё работает правильно, преобразовал в числа.
<script>
window.onload = function(){
document.getElementById('button').onclick = function() {
var balanc = "20";
var gamebalanc = "3819430";
var balanc = Number(balanc);
var gamebalanc = Number(gamebalanc);
var bits = document.getElementById("bits").value;
var stav = document.getElementById("stav").value;
var bits = Number(document.getElementById("bits").value);
var stav = Number(document.getElementById("stav").value);
function randomInteger(min, max) {
var rand = min + Math.random() * (max - min);
rand = Math.round(rand);
return rand;
}
var sum = ( randomInteger(0, 100) )
if (balanc > bits) {
if (stav < sum) {
var resbits = bits * 2;
var newuserbal = balanc + resbits;
var newgamebal = gamebalanc - resbits;
}
if (stav > sum) {
var newuserbal = balanc - bits;
var newgamebal = gamebalanc + bits;
}
}
document.getElementById('userbal').innerHTML=newuserbal;
document.getElementById('gamebal').innerHTML=newgamebal;
document.getElementById('result').innerHTML=sum;
animate({
duration: 1000,
timing: function(timeFraction) {
return Math.pow(timeFraction, 2);
},
draw: function(progress) {
brick.style.left = progress * sum + '%';
}
});
};
}
</script>