Travis build: 1179

This commit is contained in:
30secondsofcode
2018-01-11 10:28:20 +00:00
parent 66a78ee7b5
commit 84fcddd42c
7 changed files with 109 additions and 6 deletions

View File

@ -5,9 +5,9 @@ Returns the average of an array, after mapping each element to a value using the
Use `Array.map()` to map each element to the value returned by `fn`, `Array.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.
```js
const averageBy = (arr, fn) => arr.map(fn).reduce((acc, val) => acc + val, 0)/arr.length;
const averageBy = (arr, fn) => arr.map(fn).reduce((acc, val) => acc + val, 0) / arr.length;
```
```js
averageBy([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], o => o.n); // 5
averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 5
```

View File

@ -28,6 +28,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
const newPost = {
"userId": 1,
"id": 1337,

View File

@ -9,5 +9,5 @@ const maxBy = (arr, fn) => Math.max(...arr.map(fn));
```
```js
maxBy([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], o => o.n); // 8
maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8
```

View File

@ -9,5 +9,5 @@ const minBy = (arr, fn) => Math.min(...arr.map(fn));
```
```js
minBy([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], o => o.n); // 8
minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8
```

View File

@ -9,5 +9,5 @@ const sumBy = (arr, fn) => arr.map(fn).reduce((acc, val) => acc + val, 0);
```
```js
sumBy([{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }], o => o.n); // 20
sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 20
```