Created
September 25, 2015 23:00
-
-
Save luijar/acc89cb8c24128413440 to your computer and use it in GitHub Desktop.
Simple Money Value Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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