Skip to content

Instantly share code, notes, and snippets.

@JakeDuke
Created April 16, 2018 11:59
Show Gist options
  • Save JakeDuke/070e4abf6a5437b0ec70ce34ebddf54a to your computer and use it in GitHub Desktop.
Save JakeDuke/070e4abf6a5437b0ec70ce34ebddf54a to your computer and use it in GitHub Desktop.
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