
Apu
June 03, 2023 ›
#HowTo
›
#Javascript
❌
How to generate 10 random numbers between 1 and 100 in JavaScript
If you want to know how you generate random numbers between 1 and 100, then in this article, I'm going to explain how to generate 10 random numbers between 1 and 100 using JavaScript.
Example
Try it Yourself »
In the above example, we have successfully generated random numbers between 1 to 100.
- Math.random() method gives us a random numbers between 0 to 1 (1 exclusive).
- Math.floor() method returns the largest integer value that is less than or equal to a given number.
For example, Math.random() method gives 0.5 and to get the numbers upto 100 , we have to multiply 100 with the given number. So, the number is 0.5 *100 = 50
You will not able to get the 100 number, so we have added 1 with the given number.
Generate 10 random numbers on button click
Try it Yourself »
save
listen
AI Answer
How to generate 10 random numbers between 1 and 100 in JavaScript
0
If you want to know how you generate random numbers between 1 and 100, then in this artic…
asked
Apu
0 answers
2915
If you want to know how you generate random numbers between 1 and 100, then in this artic…
Answer Link
answered
Apu