File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,11 +8,11 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
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
1010
11- //num is a random, rounded down number between 100 and 1 .
11+ //num is a random whole number between 1 and 100 inclusive .
1212//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,
13+ //math.random gives a random number between 0 and 1. It can be equal to 0, but not equal to 1, and have decimals
1414//(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
15+ //So then Math.random() * (maximum - minimum + 1) gives a number between 0 inclusive and 100 exclusive
16+ //Math.random() * (maximum - minimum + 1) + minimum gives a number between 1 inclusive and 101 exclusive
1717//and thus Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; gives a whole rounded
1818//down number
You can’t perform that action at this time.
0 commit comments