Skip to content

Commit 4ee2dff

Browse files
committed
updated 4.js template
1 parent 4302f25 commit 4ee2dff

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ const maximum = 100;
33

44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

6-
// In this exercise, you will need to work out what num represents?
7-
// Try breaking down the expression and using documentation to explain what it means
8-
// It will help to think about the order in which expressions are evaluated
9-
// Try logging the value of num and running the program several times to build an idea of what the program is doing
6+
console.log(num);
7+
8+
// num is a random integer between minimum and maximum, including both endpoints.
9+
// Math.random generates random decimal numbers between 0 and 1.
10+
// Math.floor() rounds a number down to the nearest integer.Example 12.8 is rounded to 12.
11+
//(maximum - minimum + 1)= (100 - 1 + 1)= 100.... So the expression becomes (Math.random()*100)
12+
//In the output I can see random numbers between 1 and 100.
13+
14+

0 commit comments

Comments
 (0)