From fad13712d291305db6333225a490a11ea64405b4 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Mon, 15 Oct 2018 12:17:08 +0300 Subject: [PATCH] Update squareSum.md --- snippets_archive/squareSum.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets_archive/squareSum.md b/snippets_archive/squareSum.md index 3ae951334..f67f7689d 100644 --- a/snippets_archive/squareSum.md +++ b/snippets_archive/squareSum.md @@ -1,15 +1,15 @@ ### squareSum -Squares each number passed into it and then sums the results together. +Squares each number in an array and then sums the results together. -Use `Array.prototype.reduce()` to iterate over numbers and to declare an accumulater. +Use `Array.prototype.reduce()` to iterate over numbers and to declare an accumulator. Use `Math.pow()` to calculate power of each number and add all numbers into acculmulator. ```js const squareSum = (arr) => arr.reduce((squareSum, number) => - squareSum + Math.pow(number, 2), 0); + squareSum + Math.pow(number, 2), 0); ``` ```js squareSum([1, 2, 2]); // 9 -``` \ No newline at end of file +```