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,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+ //num is a random, rounded down number between 100 and 1.
12+ //math.floor rounds down.
13+ //math.random gives a random number between 0 and 1. It can be equal to 0, but not equal to 1,
14+ //(maximum - minimum + 1) gives in this case 100
15+ //So then Math.random() * (maximum - minimum + 1) gives a number between 0 and 99
16+ //Math.random() * (maximum - minimum + 1) gives a number between 1 and 100
17+ //and thus Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; gives a whole rounded
18+ //down number
You can’t perform that action at this time.
0 commit comments