Skip to content

Commit c7309cf

Browse files
Explain random number generation
1 parent b2957b1 commit c7309cf

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

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

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

44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
5-
5+
console.log(num);
66

77
// In this exercise, you will need to work out what num represents?
88
// Try breaking down the expression and using documentation to explain what it means
99
// It will help to think about the order in which expressions are evaluated
1010
// Try logging the value of num and running the program several times to build an idea of what the program is doing
1111

12-
//num represents a random whole number between 1 and 100.
12+
// Math.floor() rounds down to a whole number instead of rounding up
13+
// Math.random() gives a random decimal
14+
15+
//num represents a random whole number between 1 and 100.

0 commit comments

Comments
 (0)