Hi-
Working an ATM app in CSD Projects. Using the setNumber tool to display dollar amount in a label, however it drops the zeroes in the display i.e. 100.00 displays as 100.
Is there a way to control the number of decimal places to display?
Hi-
Working an ATM app in CSD Projects. Using the setNumber tool to display dollar amount in a label, however it drops the zeroes in the display i.e. 100.00 displays as 100.
Is there a way to control the number of decimal places to display?
you should be able to by using the .toFixed prototype, assuming the structure your using is a Number
and not a String
here’s how you would do that
var num = 100;
console.log(num.toFixed(2));
the 2 represents how many additional places you wish to see after the decimal spot hope this helps
that worked. thx!
btw: how did you even know that existed?
here is a good starting place if you wish to learn more about JS data prototypes