Skip to content

Instantly share code, notes, and snippets.

@luijar
Created September 25, 2015 23:00
Show Gist options
  • Save luijar/acc89cb8c24128413440 to your computer and use it in GitHub Desktop.
Save luijar/acc89cb8c24128413440 to your computer and use it in GitHub Desktop.
Simple Money Value Object
function money(value, currency) {
var _value = value;
var _currency = currency;
return {
value: function () {
return _value;
},
currency: function () {
return _currency;
},
toString: function () {
return _value + '-' + _currency;
}
};
}
const twoDollars = money(2,'USD'); //-> 2 USD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment