vendredi 12 juin 2020

In this Javascript code using setInterval, why isn't n a different value every time?

n is the same every loop, even though i set it differently every iteration of setInterval. Anyone know a fix or another way I can randomise n every time?

    var n = random(1000, 5000);
let toptimer = setInterval(()=>{
    n = random(1000, 5000);
    obs.push(new obstacle(800, 200, 255));
},n);



Aucun commentaire:

Enregistrer un commentaire