Merge pull request #25 from 105ron/patch-1

Update calculator.js
This commit is contained in:
Cody Loyd 2019-01-11 15:10:31 -06:00 committed by GitHub
commit a70a2503ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,7 +11,9 @@ function sum(array) {
}
function multiply(array) {
return array.reduce((current, total) => total * current, 1);
return array.length
? array.reduce((accumulator, nextItem) => accumulator * nextItem)
: 0;
}
function power(a, b) {