Skip to content

Instantly share code, notes, and snippets.

@barraponto
Forked from matheus-rossi/convertCurrency.js
Last active September 26, 2017 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barraponto/6d7ffc95f8edf25ce6063acba271ca78 to your computer and use it in GitHub Desktop.
Save barraponto/6d7ffc95f8edf25ce6063acba271ca78 to your computer and use it in GitHub Desktop.
const convertCurrency = (from, to, amount) => {
const countries = getCountries(to);
const rate = getExchangeRate(from, to);
return Promise.all([countries, rate])
.then(([countries, rate]) => {
const exchangedAmount = amount * rate
return `${amount} ${from} is worth ${exchangedAmount} ${to}. ${to} can be used in the following countries: ${countries.join(', ')}`
})
}
convertCurrency('CAD', 'USD', 100).then((status) => {
console.log(status)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment