Additional snippets

This commit is contained in:
Angelos Chalaris
2017-11-30 19:12:13 +02:00
parent 292aad75bc
commit bb40a7ec08
9 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,8 @@
### Sum of array of numbers
Use `reduce()` to add each value to an accumulator, initialized with a value of `0`.
```js
var sum = arr =>
arr.reduce( (acc , val) => acc + val, 0);
```