Skip to content

Commit 2e44be5

Browse files
committed
random num between minimum and maximum generated
1 parent b25d953 commit 2e44be5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ const minimum = 1;
22
const maximum = 100;
33

44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
5+
// num is an integer between minimum and maximum, between 1 and 100 inclusive
6+
// math.random() produces a decimal between 0 (inclusive) and 1 (exclusive)
7+
// math.floor() rounds down to the nearest integer
8+
// (maximum - minimum + 1)) + minimum chooses a number between minimum and maximum and adds 1 so its inclusive of maximum
9+
console.log(num);
510

611
// In this exercise, you will need to work out what num represents?
712
// Try breaking down the expression and using documentation to explain what it means

0 commit comments

Comments
 (0)