Update squareSum.md

This commit is contained in:
Angelos Chalaris
2018-10-16 13:55:06 +03:00
committed by GitHub
parent ba8dfd5872
commit ade6be6cd7

View File

@ -2,8 +2,7 @@
Squares each number in an array and then sums the results together.
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.
Use `Array.prototype.reduce()` in combination with `Math.pow()` to iterate over numbers and sum their squares into an accumulator.
```js
const squareSum = (...args) => args.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);