Skip to content

Commit 6ae9f42

Browse files
elaborate on the functionality of Math.floor and Math.ceil methods
1 parent 356c45f commit 6ae9f42

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
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

11-
// math.floor will make the number as a whole and remove any decimals or more likely to round the the nearest whole number
12-
// math.random returns a random number in [0,1)
11+
// math.floor round down to the nearest whole number e.g Math.floor(4.4) or Math.floor(4.8) will return 4
12+
// math.ceil round up to the nearest whole number e.g Math.ceil(4.8) and Math.ceil(4.4) will return 5
1313
// (maximum - minimum + 1) provide a range of generated random number
1414
// num is a random whole number [1,100]
15-
console.log(num);
15+
16+
console.log(Math.floor(4.8))
1617
console.log(Math.floor(4.4))
18+
console.log(Math.ceil(4.8))
1719
console.log(Math.ceil(4.4))

0 commit comments

Comments
 (0)