Skip to content

Commit 637cf89

Browse files
authored
adding comments to explain the code and adding line command to run the code
1 parent ac6b0e4 commit 637cf89

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+
console.log(num);
11+
// num is a random integer between 1 and 100.
12+
// Math.random() generates a random floating-point number between 0 and 1.
13+
// Multiplying this by (maximum - minimum + 1) scales it to a range of 0 to 100.
14+
// Math.floor() rounds down the result to the nearest integer number.
15+
// Finally, adding minimum shifts the range to be between 1 and 100.

0 commit comments

Comments
 (0)