I have an integer stored as US cents, ie 1700 cents. How can I convert that to a string that is $17.00 using javascript? I have tried toFixed and Intl.NumberFormat but they return $1700?
3 Answers
you can also try this simple javascript number format
const currencyConverter = (amount) => {
let dollars = amount/ 100;
const result = Number(dollars).toLocaleString("en-US");
return result;
}
now you have a reusable currency converter function which to use you just have to call and then pass the number into the function
currencyConverter(1700)
toFixed()andIntl.numberFormat?