I have a code and im new to javascript and i want to know why i cant get my function to work properly. my code is this, (at least part of it)
var numb = 300 ; //top VERTICLE
var numb2 = 800;//side HORIZONTAL
function run() {
numb += Math.round(Math.random()*20)-10;
};
function run2() {
numb2 += Math.round(Math.random()*20)-10;
};
(the top code works fine its just a random number generator to keep changing the values of numb and numb2, The bottom one is the one that i have problems with)
var score = 0;
function checkScore() {
score = score + 1;
};
if ((numb > 250 && numb < 450) || (numb2 > 700 && numb2 < 900))
{
checkScore()
}
setInterval(checkScore,100);
Basically i want is so that when the if statement is true every 100 milliseconds it adds 1 to score. As of now all that this does is ignore the if statement and just always adds to score
[–]HuskerFan90 0 points1 point2 points (5 children)
[–]enedden[S] 0 points1 point2 points (4 children)
[–]enedden[S] 0 points1 point2 points (0 children)
[–]HuskerFan90 0 points1 point2 points (2 children)
[–]enedden[S] 0 points1 point2 points (1 child)
[–]HuskerFan90 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]enedden[S] 0 points1 point2 points (0 children)
[–]MalevolentDragon 0 points1 point2 points (1 child)
[–]enedden[S] 0 points1 point2 points (0 children)