Skip to content

Commit fac3f30

Browse files
committed
complete 4-random ex.
1 parent 36ef980 commit fac3f30

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ 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
console.log(num);
11+
// num is a random whole number between minimum and maximum.
12+
// Math.random() gives a decimal between 0 and 1.
13+
// Then we multiply by (maximum - minimum + 1) to get a range of possible values.
14+
// Math.floor(...) turns that into a whole number.
15+
// Finally, we add minimum so the number starts at minimum instead of 0.

0 commit comments

Comments
 (0)