Skip to content

Instantly share code, notes, and snippets.

@goosecoid
Created September 18, 2017 12:13
Show Gist options
  • Save goosecoid/a9b7d5a14be37cd73c618aa054c4830e to your computer and use it in GitHub Desktop.
Save goosecoid/a9b7d5a14be37cd73c618aa054c4830e to your computer and use it in GitHub Desktop.
object for cleancalc adrien
ar calc = {
lastResult: 0000,
operate: function(operation, arg1, arg2) {
if (arg2) {
return (this.lastResult = operation(arg1, arg2));
} else {
return (this.lastResult = operation(arg1, this.lastResult));
}
},
add: function(arg1, arg2) {
return arg1 + arg2;
},
subtract: function(arg1, arg2) {
return arg1 - arg2;
},
multiply: function(arg1, arg2) {
return arg1 * arg2;
},
divide: function(arg1, arg2) {
return arg1 / arg2;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment