8000 Update calculator.js · GeraldCO/javascript-exercises@d3412c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit d3412c1

Browse files
authored
Update calculator.js
1 parent ee8f672 commit d3412c1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

calculator/calculator.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ function sum(array) {
1010
return array.reduce((current, total) => total + current, 0);
1111
}
1212

13-
function multiply(array) {
14-
return array.reduce((current, total) => total * current, 1);
13+
function multipy (array) {
14+
return array.length
15+
? array.reduce((accumulator, nextItem) => accumulator * nextItem): 0;
1516
}
1617

1718
function power(a, b) {

0 commit comments

Comments
 (0)
0