Skip to content
Advertisement

MYR Currency Rounding

Looking for help in rounding the money to the nearest 0.05 in js language.

Input & Expected Output:

JavaScript

enter image description here

From: https://www.bnm.gov.my/misc/-/asset_publisher/2BOPbOBfILtL/content/frequently-asked-questions-faqs-on-rounding-mechanism

Advertisement

Answer

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

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

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement