Skip to content

Commit b1dcb1c

Browse files
committed
4-random task completed
1 parent 6c5a8c8 commit b1dcb1c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

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

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

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

6-
// In this exercise, you will need to work out what num represents?
7-
// Try breaking down the expression and using documentation to explain what it means
8-
// It will help to think about the order in which expressions are evaluated
9-
// Try logging the value of num and running the program several times to build an idea of what the program is doing
7+
8+
// num variable that carries the result of the expressions evaluated.
9+
// (maximum - minimum) does basic math: 100 - 1 + 1 = 100
10+
// Math.floor() takes out all decimal and make them an integer.
11+
// Math.random() gives random numbers between 0 and 100.
12+
// + minimum add 1 at the end but randomise to the value between 0 and 100

0 commit comments

Comments
 (0)