Skip to content

Commit 3e9c48c

Browse files
Complete random number generator exercise
1 parent f2de098 commit 3e9c48c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,19 @@ 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+
12+
/*
13+
14+
In this exercise, num is a variable that stores the random whole number generated by the expression so it can be used later in the program.
15+
16+
1. Math.randon() picks a random decimal number
17+
18+
2. maximum - minimum + 1; finds how many numbers are in the range
19+
20+
3. Math.floor() rounds the decimal down
21+
22+
4. +minimum adds the minimum value
23+
24+
25+
*/

0 commit comments

Comments
 (0)