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+ console . log ( num ) ;
11+ // Output: A random number between 1 and 100 (inclusive both 1 and 100)
12+ //num is a random number generated between the minimum 1 and maximum values 100.
13+ // The expression Math.random() generates a random floating-point number between [0,1).
14+ // The expression (maximum - minimum + 1) calculates the range of numbers we want to generate, which is 100 - 1 + 1 = 100.
15+ // The expression Math.floor() rounds down the result to the nearest whole number.
16+ // Finally, we add the minimum value to ensure that the random number falls within the desired range.
You can’t perform that action at this time.
0 commit comments