JavaScript Number methods Flashcards
1
Q
Math.max(5,18,22,19,166, “200”)
A
returns the maximum number even if there is a string
2
Q
Math.min(4,5,6,7,87,43)
A
returns the minimum amount in the list
3
Q
Math.random()
A
generates a random number from 0.01 - 0.99
4
Q
Math.trunc(number)
A
removes the decimals or fractions
5
Q
Math.floor(number)
A
rounds to the lowest amount
6
Q
Math.ceil(number)
A
rounds up to the highest amount
7
Q
(number).toFixed(number)
A
rounds the decimals. Returns a string. Example: +(2.7).toFixed(2)
8
Q
parseFloat and parseInt
A
Both extract numbers from strings. parse float returns number with decimals while parseInt returns integers
9
Q
Math.pow(x, y)
A
returns the value of x to the power of y