File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -7,3 +7,11 @@ 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+ // The variable "num" stores a random whole number between 1 and 100.
12+ // The expression works as follows:
13+ // 1: Math.random() generates a decimal 0 to 1 (not including 1)
14+ // This decimal is multiplied by (maximum - minimum + 1) which gives a number between 0 and 99.999.
15+ // Math.floor() then rounds this down to a whole number between 0 to 99.
16+ // Adding "minimum" shifts the result so the final number is between 1 to 100.
17+ // for this reason num changes every time when you run the program always gives the number between 1 to 100.
You can’t perform that action at this time.
0 commit comments