Skip to content

Commit 5b83030

Browse files
committed
Breaking the expression down
1 parent 902061e commit 5b83030

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎Sprint-2/1-key-exercises/4-random.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
1010

1111
console.log(num);
1212
// 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)
13+
// 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

Comments
 (0)