Skip to content

Commit 9b9dc8e

Browse files
committed
answering the task
1 parent d868527 commit 9b9dc8e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,14 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
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
1010

11+
//num represents the results of equations at the right side of operator =
12+
13+
//step-1---> Math.random() generates a random decimal.
14+
//step-2---> (maximum - minimum + 1) evaluates to 100.
15+
//step-3---> Math.random() is multiplied by (maximum - minimum + 1) which is 100, resulting in a random decimal between 0 and 100.
16+
//step-4---> the result of Step-3 is round by the method Math.floor.
17+
//step-5---> minimum is added to the result of step-4.
18+
//Therefore, num represents random numbers generated between minimum 1 and maximum 100, as we run the code several times
19+
//generates new numbers.
1120

1221
console.log(num);

0 commit comments

Comments
 (0)