Skip to content

Commit b3fa1cd

Browse files
committed
answering 4-random
1 parent 8f9a606 commit b3fa1cd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@ 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+
// Math.floor - Rounds a number DOWN to the nearest integer
12+
// Math.random - generates a random floating number > 0 and < 1
13+
// (maximum - minimum + 1) = 100 - 1 + 1 = 100
14+
// So, num represents a rounded down random integer generated between 1 and 100 + 1
15+
16+
console.log(num);

0 commit comments

Comments
 (0)