Skip to content

Commit e589aee

Browse files
committed
Refine comments for clarity and accuracy in random number generation explanation
1 parent 48bc232 commit e589aee

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ console.log(num);
1010
// It will help to think about the order in which expressions are evaluated
1111
// Try logging the value of num and running the program several times to build an idea of what the program is doing
1212

13-
// num is a variable declared to hold (being assigned) the value of the calculated result of the var minimum, var maximum and the Math.random() method
14-
// This expression can be broken down in to main steps
13+
// num is a variable declared to hold (being assigned) the value of the calculated result of the var minimum,
14+
// var maximum , the Math.random() method and Math.floor() method
15+
// This expression can be broken down in to the following main steps
1516
// 1. the inner parentheses (maximum - minimum + 1) is calculated because that is the inner most expression
16-
// 2. then the Math.random() generates random number between 0 & 1 and multiply with the result of (maximum - minimum + 1)
17+
// 2. then the Math.random() generates random number which is greater than or equal to 0 but less than 1 number and multiply with the result of (maximum - minimum + 1)
1718
// 3. then the Math.floor() rounds down the result of (Math.random() * (maximum - minimum + 1)) to the nearest whole number
1819
// 4. finally the minimum is being added to the down rounded whole number and the variable num holds the value
19-
// after running the program the value of num looks like this 51,8,85,8,99,21 random numbers between 1 & 100
20+
// after running the program the value of num looks like this 51,8,85,8,99,21 random numbers that are greater than or equal to 1 but less than 100

0 commit comments

Comments
 (0)