Skip to content

Commit 71bd055

Browse files
authored
Clarify random number generation in 4-random.js
Added comments explaining the random number generation logic.
1 parent 4c43955 commit 71bd055

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Sprint-2/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 whole number between 1 and 100
12+
// Math.random() produces a random decimal from 0 up to 1 .
13+
// Math.random() * 100 produces a decimal from 0 up to 100.
14+
// Math.floor() rounds the number down to a whole number, giving 0–99.
15+
// +minimum (+1) shifts that range to 1–100.

0 commit comments

Comments
 (0)