File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,3 +7,16 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
77// Try breaking down the expression and using documentation to explain what it means
88// It will help to think about the order in which expressions are evaluated
99// Try logging the value of num and running the program several times to build an idea of what the program is doing
10+
11+ /*
12+ What 'num' represents: A random whole integer between 1 and 100 inclusive.
13+
14+ Order of evaluation breakdown:
15+ 1. (maximum - minimum + 1) // Calculates total size of target range (100).
16+ 2. Math.random() //Generates a random decimal between 0 and 0.999...
17+ 3. Math.random() * 100 // Scales decimal up to a range between 0 and 99.999...
18+ 4. Math.floor(...) // Rounds down to nearest integer, yielding 0 to 99.
19+ 5. + minimum //Shifts final range up by 1, resulting in 1 to 100.
20+ */
21+
22+ console . log ( num ) ;
You can’t perform that action at this time.
0 commit comments