Skip to content

Commit 158e7ca

Browse files
committed
updated 4-random.js
1 parent 75176a9 commit 158e7ca

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
1010

1111
console.log(num);
1212

13-
// num represents any randomly generated number between 1 and 100.
14-
// Math.random pulls a random decimal, Math.floor rounds down to nearest whole number, (maximum - minimum + 1) sets the range of 0-99.
13+
// num is a random whole number between 1 and 100 (inclusive).
14+
// Math.random() returns a decimal from 0 up to (but not including) 1.
15+
// (maximum - minimum + 1) is the number of possible values (100),
16+
// so multiplying gives a decimal from 0 up to (but not including) 100.
17+
// Math.floor rounds down, giving a whole number from 0 to 99.
18+
// Adding minimum shifts that range up to 1 to 100.

0 commit comments

Comments
 (0)