MYR Currency Rounding

Viewed 39
1 Answers

You could take an offset and take a multiple floored value.

If you need zeroes at the end take .toFixed(2).

const format = f => Math.floor((f + 0.025) * 20) / 20;

console.log([1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19].map(format));
.as-console-wrapper { max-height: 100% !important; top: 0; }

Related