File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11const minimum = 1 ;
22const maximum = 100 ;
33
4- const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
5-
4+ const num = Math . floor ( 0.9185141991554047 * ( maximum - minimum + 1 ) ) + minimum ;
5+ console . log ( num )
66// In this exercise, you will need to work out what num represents?
77// Try breaking down the expression and using documentation to explain what it means
88// It will help to think about the order in which expressions are evaluated
99// Try logging the value of num and running the program several times to build an idea of what the program is doing
1010
1111// Math.floor() - rounds down to nearest integer
12- // Math.random() - gives a random number
12+ // Math.random() - gives a random number between [0,1)
1313// (max - min + 1) - 100
14- // simple bodmas bro
14+ // simple bodmas
1515
16- // math.random = 2
17- // num = 201
16+ // example
17+ // math.random() = 0.9185141991554047
18+ // num = 92
You can’t perform that action at this time.
0 commit comments