There was an error while loading. Please reload this page.
1 parent 902061e commit 5b83030Copy full SHA for 5b83030
1 file changed
Sprint-2/1-key-exercises/4-random.js
@@ -10,4 +10,7 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
10
11
console.log(num);
12
// This expression uses a function that returns a random number between (min)1 and (max)100.
13
-// So every time I ran the program, it generated a different result (between 1 and 100)
+// So every time I ran the program, it generated a different result (between 1 and 100).
14
+// Math.random() gives a decimal between 0 < 1. I multiply it by 100 to stretch it out, then Math.floor() chops off the decimals
15
+// to make it a whole number. That gives me 0 to 99.
16
+// The minimum at the end just adds 1 to the whole thing, so now it goes from 1 to 100 instead of 0 to 99
0 commit comments