Created
April 16, 2018 11:59
-
-
Save JakeDuke/070e4abf6a5437b0ec70ce34ebddf54a to your computer and use it in GitHub Desktop.
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
var calc = { | |
lastResult: null, | |
add: function (arg1, arg2) { | |
return arg1 + arg2; | |
}, | |
substract: function (arg1, arg2) { | |
return arg1 - arg2; | |
}, | |
multiply: function (arg1, arg2) { | |
return arg1 * arg2; | |
}, | |
devide: function (arg1, arg2) { | |
return arg1 / arg2; | |
}, | |
operate: function (operation, arg1, arg2) { | |
if (arg2) { | |
return this.lastResult = this.operation(arg1, arg2); | |
} else { | |
return this.lastResult = this.operation(arg1, this.lastResult); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment