Skip to content

Instantly share code, notes, and snippets.

@matheus-rossi
Last active September 26, 2017 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matheus-rossi/7bad51d5fb4c9aeb4a656522800750aa to your computer and use it in GitHub Desktop.
Save matheus-rossi/7bad51d5fb4c9aeb4a656522800750aa to your computer and use it in GitHub Desktop.
const convertCurrency = (from, to, amount) => {
let countries
return getCountries(to).then((tempCountries) => {
countries = tempCountries
return getExchangeRate(from, to)
}).then((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