Skip to content

Commit 9cc571d

Browse files
committed
Correct explanation
1 parent 83b9be5 commit 9cc571d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
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
1010

11-
//num is a random, rounded down number between 100 and 1.
11+
//num is a random whole number between 1 and 100 inclusive.
1212
//math.floor rounds down.
13-
//math.random gives a random number between 0 and 1. It can be equal to 0, but not equal to 1,
13+
//math.random gives a random number between 0 and 1. It can be equal to 0, but not equal to 1, and have decimals
1414
//(maximum - minimum + 1) gives in this case 100
15-
//So then Math.random() * (maximum - minimum + 1) gives a number between 0 and 99
16-
//Math.random() * (maximum - minimum + 1) gives a number between 1 and 100
15+
//So then Math.random() * (maximum - minimum + 1) gives a number between 0 inclusive and 100 exclusive
16+
//Math.random() * (maximum - minimum + 1) + minimum gives a number between 1 inclusive and 101 exclusive
1717
//and thus Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; gives a whole rounded
1818
//down number

0 commit comments

Comments
 (0)