From d3412c14234ecdb34f92782f8dfe24a85e19c054 Mon Sep 17 00:00:00 2001 From: Rhys <105ron@users.noreply.github.com> Date: Thu, 27 Sep 2018 14:18:29 +0800 Subject: [PATCH] Update calculator.js --- calculator/calculator.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/calculator/calculator.js b/calculator/calculator.js index 6fa7dd9..ac5d6e1 100644 --- a/calculator/calculator.js +++ b/calculator/calculator.js @@ -10,8 +10,9 @@ function sum(array) { return array.reduce((current, total) => total + current, 0); } -function multiply(array) { - return array.reduce((current, total) => total * current, 1); +function multipy (array) { + return array.length + ? array.reduce((accumulator, nextItem) => accumulator * nextItem): 0; } function power(a, b) {