Skip to content

Commit de4738f

Browse files
committed
Add additional breakdown comments in 4-random.js
1 parent cf88162 commit de4738f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
1111
//Solution
1212
//- "num" represents a random whole number between 1 and 100.
1313
//Break down of expression
14-
//-Math.random: This generates a random decimal number between 0 and 1. It can return 0, but never reaches 1. (Example: 0.87).
14+
//-Math.random: This generates a random decimal number between 0 and 1. It can return 0, but never reaches 1. (Example: 0.87).
15+
//-(maximum - minimum + 1):
16+
// This expression can be simplified as (100 - 1 + 1), which equals 100. This tells the program how many possible whole numbers there are. There are 100 possibilities.
17+
// The +1 is important as without it, we would only reach 99 possibilities, that is 0 - 99.

0 commit comments

Comments
 (0)