Skip to content

Commit 6dbf419

Browse files
committed
Complete 4-random.js exercise
1 parent 6a17974 commit 6dbf419

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ 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+
// num represents a random number in an inclusive range from 1 to 100
12+
// First, it starts with 100 - 1 + 1, which is equals to 100
13+
// Secondly, it multiply with Math.random(), which the function returns any number between 0 and 1, inclusive.
14+
// Thirdly, Math.floor() rounds down and returns the largest integer less than or equal to a given number
15+
// Finally, it adds 1

0 commit comments

Comments
 (0)