File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -7,3 +7,22 @@ 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+ console . log ( `Random number between ${ minimum } and ${ maximum } : ${ num } ` ) ;
12+
13+ console . log (
14+ "Random number between 0 and 1 after evaluating Math.random() is: " ,
15+ Math . random ( )
16+ ) ;
17+ console . log (
18+ "Math.random() * (maximum - minimum + 1) scales the range from 1 to 100 (100 isn't included) for the random number: " ,
19+ Math . random ( ) * ( maximum - minimum + 1 )
20+ ) ;
21+ console . log (
22+ "Math.floor(Math.random() * (maximum - minimum + 1)) rounds down the random number: " ,
23+ Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) )
24+ ) ;
25+ console . log (
26+ "(Math.floor(Math.random() * (maximum - minimum + 1)) + minimum) shifts the range to 1–100 (100 is included): " ,
27+ Math . floor ( Math . random ( ) * ( maximum - minimum + 1 ) ) + minimum
28+ ) ;
You can’t perform that action at this time.
0 commit comments