diff --git a/src/functions/countryToCurrency.js b/src/functions/countryToCurrency.js index 13f7b2a..f4808fa 100644 --- a/src/functions/countryToCurrency.js +++ b/src/functions/countryToCurrency.js @@ -1,8 +1,13 @@ import currencyData from '../api/currencies.json' export function countryToCurrency(countryCode) { + let printedCurr = '' let matchedCurrency = Object.values(currencyData).find((c) => c.code.slice(0, 2) === countryCode) - let printedCurr = `${matchedCurrency.symbol_native} ${matchedCurrency.code}` + if (!matchedCurrency) { + printedCurr = '$ USD' + } else { + printedCurr = `${matchedCurrency.symbol_native} ${matchedCurrency.code}` + } return printedCurr }