diff --git a/08_calculator/solution/calculator-solution.js b/08_calculator/solution/calculator-solution.js index 0a247ec..ab39a60 100644 --- a/08_calculator/solution/calculator-solution.js +++ b/08_calculator/solution/calculator-solution.js @@ -10,11 +10,13 @@ const sum = function (array) { return array.reduce((total, current) => total + current, 0); }; -const multiply = function (array) { - return array.length - ? array.reduce((accumulator, nextItem) => accumulator * nextItem) - : 0; -}; +const multiply = function(...args){ + let product = 1; + for (let i = 0; i < args.length; i++) { + product *= args[i]; + } + return product; + }; const power = function (a, b) { return Math.pow(a, b);