We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6b302e3 + 175ee76 commit 8692f0eCopy full SHA for 8692f0e
08_calculator/solution/calculator-solution.js
@@ -10,11 +10,13 @@ const sum = function (array) {
10
return array.reduce((total, current) => total + current, 0);
11
};
12
13
-const multiply = function (array) {
14
- return array.length
15
- ? array.reduce((accumulator, nextItem) => accumulator * nextItem)
16
- : 0;
17
-};
+const multiply = function(...args){
+ let product = 1;
+ for (let i = 0; i < args.length; i++) {
+ product *= args[i];
+ }
18
+ return product;
19
+ };
20
21
const power = function (a, b) {
22
return Math.pow(a, b);
0 commit comments