I have an array that consists of currency words and numbers. I need to round DIME and NICKEL values to 3.1 and 2.05 correspondingly
[
[ ' ONE HUNDRED: $', 100 ],
[ ' TWENTY: $', 60 ],
[ ' TEN: $', 20 ],
[ ' FIVE: $', 55 ],
[ ' ONE: $', 90 ],
[ ' QUARTER: $', 4.25 ],
[ ' DIME: $', 3.1000000000000014 ],
[ ' NICKEL: $', 2.0500000000000007 ],
[ ' PENNY: $', 0.05 ]
]
I tried to use toFixed
and map
methods, they didn’t work.
let my array = arr.map(e => e[1].toFixed(2)