File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,8 +2,12 @@ const minimum = 1;
22const maximum = 100 ;
33
44const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
5+ console . log ( `${ num } ` ) ;
56
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
7+ //num represents a random whole number between 1 and 100,
8+ //first we calculate value inside parentheses(maximum - minimum +1) = 100 -1 + 1 =100
9+ // math.random return number between 0 and 1
10+ // math.random() * 100 give us a integer number
11+ // math.floor round down the number
12+ // add 1 to the result
13+ //for example math.floor((0.783 *100))=78 + 1 = 79
You can’t perform that action at this time.
0 commit comments