File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- const minimum = 1 ;
2- const maximum = 100 ;
1+ const minimum = 1 ; // Sets the lowest possible number that can be generated
2+ const maximum = 100 ; // Sets the highest possible number that can be generated
33
4- const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
54
65// In this exercise, you will need to work out what num represents?
76// Try breaking down the expression and using documentation to explain what it means
87// It will help to think about the order in which expressions are evaluated
8+
9+ const num = Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum ;
10+ // Math.random() returns a random decimal between 0 and 1
11+ // Math.random() * maximum(100) returns a random decimal between 0 and 99.999
12+ // Math.floor() rounds up the decimal to the nearest whole number
13+ // maximum and minimum calculates thee total output of the number(100)
14+
915// Try logging the value of num and running the program several times to build an idea of what the program is doing
16+
17+ console . log ( num ) ; // num represents a random whole number between 1 and 100
You can’t perform that action at this time.
0 commit comments