0
Var help
Can you make a variation go radomly between numbers? Example (this is very wrong but i want you to get the picture): var a = 10-20; document.getElementById(“ID”).innerHTML = a; I know this is wrong but is it possible to do it even in a longer way of coding it? If its not possible its ok to tell me.
9 Respostas
+ 7
Something like this will do the trick. May not be the simplest way, but I'm still learning :)
https://code.sololearn.com/W3QNFabgpBP7/#html
Note: I have set an infinite interval going. You can stop it using clearInterval(changeIt); within an 'if' statement within the changeIt function.
+ 6
The standart formula for that is
a = Math.floor(min+(max-min)*Math.random());
+ 5
Var a = Math.floor(Math.random() * 11) + 10;
this will generate a random integer value, between 10 and 20 (including 10 and 20)
+ 4
@Will Cavalcanti, your solution doesn't include 10
What you might want is floor(rand()*11)+10) instead
+ 3
I'm not absolutely certain to get what you mean, do you want a randomly chosen number between, here, 10 and 20?
+ 1
yup my mistake
+ 1
You're welcome! :')
+ 1
Thanks everyone!
0
So the value of that is now random between that number?