Skip to content

Commit 21231d3

Browse files
committed
updated the code explaination
1 parent 762dcdf commit 21231d3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ num = Math.floor(Math.random() * (maximum - minimum) + 1);
1616
// between 1 and 100. Math.random() generates a random decimal number between 0 and 1 (exclusive).
1717
// then it multiplies this random number by (maximum - minimum) to scales it to a range between 0 and 99 (since maximum is 100 and minimum is 1).
1818
// Adding 1 shifts this range to be between 1 and 100.
19+
// the line had a mistake, it was declared as const num = ... but I changed it to num = ... because const means unchangeable, and here we want to change its value each time we run the code.
1920
// Math.floor() then rounds down the result number to the nearest whole number, and ensures that num is an integer between 1 and 100.
2021

2122
// So the whole code generates a random integer between 1 and 100 (inclusive) and stores it in the variable num.

0 commit comments

Comments
 (0)