Skip to content

Commit 1e4ccf1

Browse files
Expressed the functions with documentation explanation and include the console.log results in five multiple loggings.
1 parent d2d32a4 commit 1e4ccf1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,21 @@ 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+
//Math.random() returns a random number/ decimal number between 0 (inclusive), and 1 (exclusive).
14+
15+
//Math.random() always returns a number lower than 1.
16+
17+
// * (maximum - minimum + 1) multiplying by this is to give a range of possible values.
18+
19+
// adding the minimum at the end is to give a range value between the minimum and maximum inclusive.
20+
21+
// Math.floor usually rounds the number down to the nearest integer.
22+
23+
console.log (num); // first print is 24
24+
console.log (num); // second print 3
25+
console.log (num); // third print is 17
26+
console.log (num); // fourth print is 70
27+
console.log (num); // fifth print is 7

0 commit comments

Comments
 (0)