chore: minor updat
This commit is contained in:
@ -6,10 +6,9 @@ Use `Array.prototype.reduce()` to iterate over numbers and to declare an accumul
|
|||||||
Use `Math.pow()` to calculate power of each number and add all numbers into acculmulator.
|
Use `Math.pow()` to calculate power of each number and add all numbers into acculmulator.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const squareSum = (arr) => arr.reduce((squareSum, number) =>
|
const squareSum = (...arr) => arr.reduce((squareSum, number) => squareSum + Math.pow(number, 2), 0);
|
||||||
squareSum + Math.pow(number, 2), 0);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
squareSum([1, 2, 2]); // 9
|
squareSum(1, 2, 2); // 9
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user