Travis build: 1185

This commit is contained in:
30secondsofcode
2018-01-11 11:47:13 +00:00
parent bcc05a9a6e
commit b2105b096e
6 changed files with 71 additions and 19 deletions

View File

@ -6,7 +6,8 @@ Use `Array.map()` to map each element to the value returned by `fn`, `Array.redu
```js
const averageBy = (arr, fn) =>
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) / arr.length;
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /
arr.length;
```
```js

View File

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

View File

@ -5,11 +5,10 @@ Returns the maximum value of an array, after mapping each element to a value usi
Use `Array.map()` to map each element to the value returned by `fn`, `Math.max()` to get the maximum value.
```js
const maxBy = (arr, fn) =>
Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
```
```js
maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8
maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }],'n'); // 8
maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 8
```

View File

@ -5,8 +5,7 @@ Returns the minimum value of an array, after mapping each element to a value usi
Use `Array.map()` to map each element to the value returned by `fn`, `Math.min()` to get the maximum value.
```js
const minBy = (arr, fn) =>
Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
```
```js