File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -7,3 +7,12 @@ 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 ( num ) ;
12+
13+ // this will make a random number between 1-100. Math.random will give us a number between 0-1 (both ends included).
14+ // (maximum - minimum + 1): this is equal to 100-1+1=100 in this example.
15+ // (Math.random() * (maximum - minimum + 1)): this will multiply the random number which is between 0-1 by 100 so we have a number.
16+ // Math.floor: this will round the number to the nearest lower whole number.
17+ // + minimum: will add 1 (the defined minimum) to the number so it never be below 1.
18+ // so we end up with a random number between 1-100
You can’t perform that action at this time.
0 commit comments