I would like to set a random number between 200 and 300 and then randomly decrease it, step by step every 5 seconds, until it reaches 0.
I only have the beginning where i set the initial number
<div id="object_nb"></div>
<script>
function loadRandom() {
var number_objects = 200 + Math.floor(Math.random() * 100);
$('#object_nb').text(number_objects);
}
loadRandom(); // initial display
setInterval(function() {
???????? // it executes a random decrease every 5sec
},5000);
</script>
How can I achieve this random decrease until 0 ?
Note: i would like to decrease each time the number by a random number ranging from 1 to 5 (not more)
Aucun commentaire:
Enregistrer un commentaire