Getting Uncaught RangeError: Invalid currency code : â¦
even though the currency code is correct
see my function below
export const toCommaAmount = (origNum) => {
console.log("inside toCommaAmount")
let newNum = origNum
if (origNum !== null) {
if (typeof origNum == 'string') {
newNum = Number(origNum);
}
const options = {
style: 'currency',
currency: 'u20A6'
}
const intNum = new Intl.NumberFormat('en-US', options).format(newNum);
return intNum.toString()
}
2
Answers
I figured it out thanks
If you check the documentation you can see that the value of
currency
can only be ISO 4217 currency codes.So for Nigeria (as far is I’m aware
u20A6
is the currency symbol for Naira) you can use: