Skip to content

Commit 6ee9a5b

Browse files
committed
Fixed explanation regarding math.random()
1 parent 4fef432 commit 6ee9a5b

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
const minimum = 1;
22
const maximum = 100;
33

4-
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
5-
4+
const num = Math.floor(0.9185141991554047 * (maximum - minimum + 1)) + minimum;
5+
console.log(num)
66
// In this exercise, you will need to work out what num represents?
77
// Try breaking down the expression and using documentation to explain what it means
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
1010

1111
// Math.floor() - rounds down to nearest integer
12-
// Math.random() - gives a random number
12+
// Math.random() - gives a random number between [0,1)
1313
// (max - min + 1) - 100
14-
// simple bodmas bro
14+
// simple bodmas
1515

16-
// math.random = 2
17-
// num = 201
16+
// example
17+
// math.random() = 0.9185141991554047
18+
// num = 92

0 commit comments

Comments
 (0)