Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
2

Random Number in JavaScript

ruiwenge2
ruiwenge2

How do I get a random number between 10 and 20 in js using Math.random?

1 year ago

Voters

Comments

TopNew
1
1
VulcanWM
VulcanWM

Use the code below:

Math.floor(Math.random() * 20) + 10;

1 year ago
1
ruiwenge2
ruiwenge2

@VulcanWM
wait no its actually Math.floor(Math.random() * 10) + 10

1 year ago
1
VulcanWM
VulcanWM

oh yeah i thought u meant 1 to 20 sorry

@ruiwenge2

1 year ago
Load more