8000 Merge pull request #25 from 105ron/patch-1 · RebSin/javascript-exercises@a70a250 · GitHub
[go: up one dir, main page]

Skip to content

Commit a70a250

Browse files
authored
Merge pull request TheOdinProject#25 from 105ron/patch-1
Update calculator.js
2 parents ee8f672 + 3e28169 commit a70a250

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

calculator/calculator.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ function sum(array) {
1111
}
1212

1313
function multiply(array) {
14-
return array.reduce((current, total) => total * current, 1);
14+
return array.length
15+
? array.reduce((accumulator, nextItem) => accumulator * nextItem)
16+
: 0;
1517
}
1618

1719
function power(a, b) {

0 commit comments

Comments
 (0)
0