Travis build: 1185
This commit is contained in:
@ -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
|
||||
|
||||
@ -31,6 +31,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
|
||||
|
||||
|
||||
|
||||
|
||||
const newPost = {
|
||||
"userId": 1,
|
||||
"id": 1337,
|
||||
|
||||
@ -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
|
||||
```
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user