Skip to content

Commit 2d115ce

Browse files
described what each method does and the order each expression is evaluated
1 parent cb1e645 commit 2d115ce

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ const maximum = 100;
44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

66
// In this exercise, you will need to work out what num represents?
7+
//num represents a variable with the a random number as its value
8+
79
// Try breaking down the expression and using documentation to explain what it means
10+
//Math.random() returns a pseudo random number that's >=0 and <1
11+
//Math.floor() rounds down to the nearest integer
12+
813
// It will help to think about the order in which expressions are evaluated
14+
//this first (maximum-minimum+1) then this Math.random()* then this Math.floor() then this +minimum
15+
916
// Try logging the value of num and running the program several times to build an idea of what the program is doing
17+
//it returns a pseudo random number that's >=0 and <1
18+
19+
20+
console.log(num);

0 commit comments

Comments
 (0)