Link to home
Start Free TrialLog in
Avatar of tesmc
tesmcFlag for United States of America

asked on

XJS: add currency to price variable that contains no decimals

I have
var price =2799
var NumberOfDecimals = nodeCurrencyCode.GetAttribute("NumberOfDecimals");

i want to update price such that it conforms to the NumberOfDecimals present.

ie. if NumberOfDecimals == 2 then price = 27.99
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tesmc

ASKER

thanks.
Avatar of tesmc

ASKER

quick question on this, if var price =2900 or var price =3040 your solution doesn't take into account the trailing zeros.
instead it outputs 29 and 30.4
I'd like 29.00 and 30.40

how can i do that?