Created
September 18, 2017 12:13
-
-
Save goosecoid/a9b7d5a14be37cd73c618aa054c4830e to your computer and use it in GitHub Desktop.
object for cleancalc adrien
This file contains hidden or 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
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