File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1+ // In this exercise, you will need to work out what num represents?
2+ // Try breaking down the expression and using documentation to explain what it means
3+ // It will help to think about the order in which expressions are evaluated
4+ // Try logging the value of num and running the program several times to build an idea of what the program is doing
5+
16const minimum = 1 ;
27const maximum = 100 ;
38
49const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
10+ //this line will generate a random number between minimum and maximum (inclusive)
11+ // and math.floor will remove decimal part
512
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
13+ Math . floor ( ) //removes decimal part and returns whole number
14+ Math . random ( ) //needs to values between minimum and maximum to generate a random number
15+
16+ console . log ( maximum - minimum + 1 ) + minimum ; // this is same as 100 - 1 + 1 = 100
17+ console . log ( `The random number is ${ num } ` ) ;
You can’t perform that action at this time.
0 commit comments