File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,8 +10,6 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
1010console . log ( num ) ;
1111// num is a random whole number between minimum and maximum.
1212// Math.random() returns a number that's greater than or equal to 0 and less than 1.
13- /*Then we multiply by (maximum - minimum + 1) to get a range of possible values, which means
14- all the values num could end up being. In this program, num can be any whole number from 1 to 100, inclusive
15- so both 1 and 100 are possible.*/
16- // Math.floor(...) turns that into a whole number.
17- // Finally, we add minimum so the number starts at minimum instead of 0.
13+ // Multiplying by 100 gives a value from 0 (inclusive) up to 100 (exclusive).
14+ // Math.floor(...) makes that an integer from 0 to 99.
15+ // Adding minimum (1) shifts the result to an integer from 1 to 100, inclusive.
You can’t perform that action at this time.
0 commit comments