File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -7,3 +7,21 @@ 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+
13+ //Math.random() returns a random number/ decimal number between 0 (inclusive), and 1 (exclusive).
14+
15+ //Math.random() always returns a number lower than 1.
16+
17+ // * (maximum - minimum + 1) multiplying by this is to give a range of possible values.
18+
19+ // adding the minimum at the end is to give a range value between the minimum and maximum inclusive.
20+
21+ // Math.floor usually rounds the number down to the nearest integer.
22+
23+ console . log ( num ) ; // first print is 24
24+ console . log ( num ) ; // second print 3
25+ console . log ( num ) ; // third print is 17
26+ console . log ( num ) ; // fourth print is 70
27+ console . log ( num ) ; // fifth print is 7
You can’t perform that action at this time.
0 commit comments