Skip to content

Commit 0ae0a4e

Browse files
committed
Complete random number exercise
1 parent b865732 commit 0ae0a4e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ 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+
// num represents a random whole number between 1 and 100 inclusive.
11+
// Math.random() generates a random number from 0 up to, but not including, 1.
12+
// The calculation scales this to the required range, Math.floor() rounds it down,
13+
// and adding minimum makes the range start at 1.

0 commit comments

Comments
 (0)