+ 4
How do I add a random number in HTML or JAVASCRIPT
in other languages I can use randint
3 Antworten
+ 9
Hello,
In JavaScript:
⭐Math.random()⭐
returns a random number in range [0,1) (excluding 1)
Now, with this method you can generate random integes in range (a,b) using the expression:
r = Math.floor(Math.random() *(b-a+1)) + a
r now holds an integer between a and b
+ 2
thank mizo.
+ 1
how did you get that