File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,12 @@ 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 minimum and maximum, including both endpoints.
9+ // Math.random generates random decimal numbers between 0 and 1.
10+ // Math.floor() rounds a number down to the nearest integer.Example 12.8 is rounded to 12.
11+ //(maximum - minimum + 1)= (100 - 1 + 1)= 100.... So the expression becomes (Math.random()*100)
12+ //In the output I can see random numbers between 1 and 100.
13+
14+
You can’t perform that action at this time.
0 commit comments