From 645cbc746fd83b31bf5cac49ba6aafd1054a8da7 Mon Sep 17 00:00:00 2001 From: seoul2045 Date: Thu, 16 May 2019 09:49:12 +0700 Subject: [PATCH] Update calculator.js The reduce() method syntax for callbacks assigns the accumulator value followed by the currentValue, so I think the above variables should be switched. --- calculator/calculator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/calculator/calculator.js b/calculator/calculator.js index 2e08f49..fe548f7 100644 --- a/calculator/calculator.js +++ b/calculator/calculator.js @@ -7,7 +7,7 @@ function subtract(a, b) { } function sum(array) { - return array.reduce((current, total) => total + current, 0); + return array.reduce((total, current) => total + current, 0); } function multiply(array) {