Skip to content

Commit ac3cfef

Browse files
committed
Updates on the key exercise of random numbers
1 parent c590ae8 commit ac3cfef

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
1010

1111
console.log(num);
1212

13-
// Here, Math.random creates a random number between 0 to 1 and Math.floor rounds down to the nearest integer.
14-
// After creating a random number between 0 and 1, we will multiply it by the result of (100 - 1 + 1), then round it down to the nearest integer
13+
// Here, Math.random creates a random decimal number greater than or equals to 0 and less than 1. It can be any decimal number in between.
14+
// The function Math.floor rounds down any decimal number to the nearest integer to give it a whole number.
15+
//In Javascript, the the expression in the bracket is read first. Here, we started by doing (maximum - minimum + 1) which is (100 - 1 + 1). The answer is 100.
16+
// The next evaluation is creating a random number by reading the function Math.random(0<= random number < 1), we will multiply it by the result of (100 - 1 + 1 which is 100), then round it down to the nearest integer
1517
// Then add all of that to 1 which is the minimum number.

0 commit comments

Comments
 (0)