Skip to content

Commit 69134dc

Browse files
committed
Fix typo in random number generation explanation and enhance comments for clarity
1 parent e589aee commit 69134dc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ console.log(num);
1414
// var maximum , the Math.random() method and Math.floor() method
1515
// This expression can be broken down in to the following main steps
1616
// 1. the inner parentheses (maximum - minimum + 1) is calculated because that is the inner most expression
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)
17+
// 2. then the Math.random() generates random number which is greater than or equal to 0 but less than 1 and multiply with the result of (maximum - minimum + 1)
1818
// 3. then the Math.floor() rounds down the result of (Math.random() * (maximum - minimum + 1)) to the nearest whole number
1919
// 4. finally the minimum is being added to the down rounded whole number and the variable num holds the value
2020
// 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
21+
22+
// the expression maximum - minimum + 1 determines how many possible whole numbers can the random method generate
23+
// and it affects the range by stretching it out to be exactly as wide as the total count of numbers we need.
24+
// the + minimum at the end makes the starting point for our random numbers to be the value of the minimum instead of 0

0 commit comments

Comments
 (0)