File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,3 +7,14 @@ 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+ console . log ( num ) ;
12+
13+ // Math.floor()= rounds a number down to the nearest integer
14+ // Math.random() = generates a random float number between 0 and 1 (not including 1)
15+ // Math.random() * 100 = generates a random float number between 0 and 99.999...
16+ // (maximum - minimum + 1) -> scales the range of random numbers to be between the minimum and maximum values (including the maximum value)
17+ // + minimum -> shifts the range of random numbers to start from the minimum value instead of 0
18+ // So, the expression generates a random integer between the minimum and maximum values (inclusive)
19+ // num = a random integer between 1 and 100 (including 100)
20+
You can’t perform that action at this time.
0 commit comments