Skip to content

Latest commit

 

History

History
31 lines (19 loc) · 606 Bytes

File metadata and controls

31 lines (19 loc) · 606 Bytes

Math

Javascript Math functions are useful for number calculus, for example:

In this code we can use floor from Math to reduce the decimal number to the next low whole number.

var n1 = 43.4

var n2 = Math.floor(n1)
console.log(n2) // Expect to be 43

On the other hand, we can use cell to get the next up whole number from a float number.

var n1 = 43.6

var n2 = Math.ceil(n2)
console.log(n2) // Expect to be 44

To get a random number we can use random method

var randomNumber = Math.random()
console.log(randomNumber) // random number