Skip to content

Commit 4acb026

Browse files
committed
updated the random file with my understanding of the logic
1 parent fe9563c commit 4acb026

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ const minimum = 1;
22
const maximum = 100;
33

44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
5+
// (0.68 * 100 ) + 1
6+
console.log(num)
57

68
// In this exercise, you will need to work out what num represents?
79
// Try breaking down the expression and using documentation to explain what it means
810
// It will help to think about the order in which expressions are evaluated
911
// Try logging the value of num and running the program several times to build an idea of what the program is doing
12+
13+
// Answer: For calculations i utilised BODMAS formula solving numbers in brackets first, multiplication, subtraction and addition
14+
// I used 0.68 for math.floor(random number) + 1
15+
// Sum = 69

0 commit comments

Comments
 (0)