When working with my MongoDB and Node backend, I need to calculate total dollar amounts and send that information to the front end. It's important to note that I am only displaying totals and not making any changes to the values themselves. To ensure that the totaled dollar values show up with two decimal places, I use the following code snippet:
let roundedTotalOpenBalance = math.round(totalOpenBalance, 2);
This code will provide me with a result like -- 322.45
-- which is exactly what I'm looking for.
However, in cases where the total value is 322
, I would like to display it on the front end as 322.00
. Is there a way to achieve this using math.js? Or should I handle the transformation manually?