+17

@vitya how did you generate the random numbers?

https://code.sololearn.com/Wd7S3ZbybqK7/?ref=app

12/13/2019 9:49:38 PM

Guy3

3 Answers

New Answer

+23

Well I used Math.random() method together with Math.round() method. A multiplier is used to define the maximum value of the generated number. Those are 3 things required to do that. This is how it works. Math.random() generates a long decimal number. It's not truly random, but it's unpredictable so one can call it "random". However, I don't need the precision of a long decimal so I use one of the method to round the number. In that code I used Math.round() method, which rounds the number up. Math.floor() method can be used instead of Math.round(), but it rounds the number down. Math.ceil() is similar to Math.round(). It also rounds the number up.

+15

"I set the browser to accept all cookies" It's show and tell time. I decided to visualize my explanation of creating random numbers. For that I reworked the prototype code, added more controls and ways to get a random number. I hope it will help you understand this topic better. Have fun with it! https://code.sololearn.com/Waji2iM7FwNj/?ref=app

+14

Vitya Thanks for your help👍😁😁!!!