File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -7,3 +7,10 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
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() generates a random decimal number between 0 and 1.
12+ // Since the minimum is 1 and maximum is 100 the bracket (maximum - minimum + 1) will always equal 100.
13+ // The random decimal number is then multiplied by 100, resulting in a random decimal number between 0 and 100.
14+ // Math.floor() then rounds this decimal number down to the nearest whole number.
15+ // Finally, the minimum value (1) is added
16+ // Resulting in a final value of num being a random whole number between 1 and 100.
You can’t perform that action at this time.
0 commit comments