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+ // This code generates a random number between 1 and 100, inclusive.
12+ // The Math.random() function generates a random floating-point number between 0 (inclusive) and 1 (exclusive).
13+ // The expression (maximum - minimum + 1) calculates the range of numbers we want to include.
14+ // By multiplying Math.random() by this range, we scale the random number to fit within the desired range.
15+ // The Math.floor() function rounds down the result to the nearest whole number.
16+ // Finally, we add the minimum value to ensure the result starts from the minimum value.
You can’t perform that action at this time.
0 commit comments