I have an array of numbers that I would like to round up so that it will always end with #.#0
or #.#5
. But when I tried either Math.round
or Math.ceil
they are returning me integers.
let result = []
const numbers = [
3.33, // 3.35
1.00, // 1.00
1.11, // 1.15
1.50, // 1.50
5.99, // 6.00
5.66, // 7.00
]
result = numbers.map(number => Math.round(number, 2))
result = numbers.map(number => Math.ceil(number, 2))
console.log(result)
This is the result I get
[
4,
1,
2,
2,
6,
6,
]
But I am trying to achieve this result
[
3.35
1.00
1.15
1.50
6.00
7.00
]
let result = []
const numbers = [
3.33, // 3.35
1.00, // 1.00
1.11, // 1.15
1.50, // 1.50
5.99, // 6.00
5.66, // 7.00
]
result = numbers.map(number => Math.round(number, 2))
result = numbers.map(number => Math.ceil(number, 2))
console.log(result)