Skip to content

Commit 7756bdd

Browse files
committed
complete key-exercise 4
1 parent d76ee44 commit 7756bdd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
77
// Try breaking down the expression and using documentation to explain what it means
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
10+
11+
console.log(num)
12+
13+
// num in this case returns to us a random number when ran in the console
14+
// Math.floor is used to round a number down to nearest integer
15+
// Math.random returns a random number between 0 and 1, and when multiplied by an exclusive number, say 10, then the Math.random function returns a number between 0 and 10
16+
// the (Maximum - minimum + 1) is to calculate the size the numbers we want
17+
// + minimum at the end adds the minimum value back so that the selected number never goes below the minimum

0 commit comments

Comments
 (0)