Skip to content

Commit 09045cf

Browse files
debug2604debug2604
authored andcommitted
Answer modified in 4-random.js
1 parent 42df165 commit 09045cf

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
const minimum = 1;
2-
const maximum = 100;
3-
4-
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
5-
6-
// 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
8-
// It will help to think about the order in which expressions are evaluated
9-
// Try logging the value of num and running the program several times to build an idea of what the program is doing
1+
const minimum = 1;
2+
const maximum = 100;
3+
4+
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
5+
6+
// 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
8+
// It will help to think about the order in which expressions are evaluated
9+
// Try logging the value of num and running the program several times to build an idea of what the program is doing
10+
11+
// num represents a variable. The expression assign a value to this variable.
12+
// Math.floor () and Math.random () are methods.
13+
// The value inside Math.floor() is its argument. The return value of this argument is expression within the yellow parenthesis.
14+
// The whole expression of variable "num" is that a float generated by method Math.random() is multiplied by return value of the range specified by value between declared variable by key word constant.
15+
// The method Math.floor() then return greatest integer of the value of this product.
16+
// And finally plus the value of minimum variable declared.
17+
18+
19+
console.log(num)

0 commit comments

Comments
 (0)