You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Try breaking down the expression and using documentation to explain what it means
8
8
// It will help to think about the order in which expressions are evaluated
9
9
// Try logging the value of num and running the program several times to build an idea of what the program is doing
10
+
11
+
// breaking down the expressions:
12
+
// num is assigned the value of Math.floor(Math.random() * (maximum - minimum + 1)) + minimum
13
+
// Math.random() generates a random decimal number between 0 (inclusive) and 1 (exclusive)
14
+
// (maximum - minimum + 1) calculates the range of possible values, which is 100 - 1 + 1 = 100
15
+
// Math.random() * (maximum - minimum + 1) scales the random decimal to the range of possible values, resulting in a number between 0 and 100 (exclusive)
16
+
// Math.floor() rounds down the scaled random number to the nearest whole number, giving us an integer between 0 and 99
17
+
// Finally, adding minimum (which is 1) shifts the range from 0-99 to 1-100, resulting in num being a random integer between 1 and 100 (inclusive)
0 commit comments