Skip to content

Commit 09f6da9

Browse files
committed
modified: Sprint-1/1-key-exercises/4-random.js
1 parent ec6019a commit 09f6da9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ const maximum = 100;
44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

66
// In this exercise, you will need to work out what num represents?
7-
// Try breaking down the expression and using documentation to explain what it means
7+
// Try breaking down the expression and using documentation to explain what it mean
88
// It will help to think about the order in which expressions are evaluated
99
// Try logging the value of num and running the program several times to build an idea of what the program is doing
10+
num reprents the number is randomly generated whole number betweeb 1 and 100,inclusive
11+
Math.random() returns a random decimal between 0(inclusive) and 1(exclusive). while maximum-minimum +1=100, Math.random()*(maximum-matchMedia+1)
12+
range is between 0 and 99.99999
13+
Due to that Math.floor(...) rounds down the decimal to the nearest whole number.From this Stage, we have interger between o and 99.
14+
After + minimum, the range is between 1 and 100.
15+
This is classcial expressions for generating a random interger between two values- between 1 and 100, inclusive in this function.
16+
This kind of expression is commonly used for things like: rolling dice,random quiz questions, game mechanics.

0 commit comments

Comments
 (0)