diff --git a/src/makeCalculator.js b/src/makeCalculator.js index c8297101..e8014ae5 100644 --- a/src/makeCalculator.js +++ b/src/makeCalculator.js @@ -4,7 +4,37 @@ * @return {object} */ function makeCalculator() { - // write code here + return { + result: 0, + + add(value) { + this.result += value; + }, + + subtract(value) { + this.result -= value; + }, + + multiply(value) { + this.result *= value; + }, + + divide(value) { + this.result /= value; + }, + + reset() { + this.result = 0; + + return this; + }, + + operate(callback, value) { + callback.call(this, value); + + return this; + }, + }; } module.exports = makeCalculator;