File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,10 @@ const maximum = 100;
33
44const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
55
6- // In this exercise, you will need to work out what num represents?
7- // Try breaking down the expression and using documentation to explain what it means
8- // It will help to think about the order in which expressions are evaluated
9- // Try logging the value of num and running the program several times to build an idea of what the program is doing
6+ console . log ( num ) ;
7+
8+ // num is a random integer between 1 and 100 (inclusive).
9+ // Math.random() returns a decimal in the range [0, 1).
10+ // Multiplying by (maximum - minimum + 1) scales it to the size of the range.
11+ // Math.floor(...) converts it to an integer.
12+ // Adding minimum shifts the range to start at 1 instead of 0.
You can’t perform that action at this time.
0 commit comments