Skip to content

Instantly share code, notes, and snippets.

@umar-siddiqui
Last active January 14, 2018 08:32
Show Gist options
  • Save umar-siddiqui/ef8d7d1ff8d1f98f794b32253f75d209 to your computer and use it in GitHub Desktop.
Save umar-siddiqui/ef8d7d1ff8d1f98f794b32253f75d209 to your computer and use it in GitHub Desktop.
closure exp for currency conversion
function currencyUsd(rate) {
return function(amt) { return (amt / rate) + ' USD' }
}
inrToUsd = currencyUsd(65)
krwToUsd = currencyUsd(1058)
inrToUsd(65) // 1 USD (65inr is 1usd)
krwToUsd(1058) // 1 USD (1058krw is 1usd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment