File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,12 @@ const maximum = 100;
33
44const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
55
6- // In this exercise, you will need to work out what num represents?
6+ // 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
10+
11+ // Math.random() gives a random decimal number between 0 and 1
12+ // Math.random() * (maximum - minimum + 1) gives a random decimal number between 0 and 100
13+ // Math.floor() removes the decimal part, giving a whole number between 0 and 99
14+ // + minimum shifts the range up so the final result is between 1 and 100
You can’t perform that action at this time.
0 commit comments