Skip to content

Commit bde2550

Browse files
committed
random done
1 parent c743686 commit bde2550

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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+
// This code generates a random number between 1 and 100 (inclusive of 100).
12+
// Math.random() produces a pseudo-random number greater than or equal to 0 and less than 1.
13+
// That number is multiplied by the total count of possible values we want, in this case 100.
14+
// The + 1 in (maximum - minimum + 1) ensures that 100 is one of the possible values of num.
15+
// the + minimum at the end makes 1 the lowest value possible.

0 commit comments

Comments
 (0)