Travis build: 887

This commit is contained in:
Travis CI
2018-01-03 06:17:04 +00:00
parent 6725fda47e
commit 1e1e98582e
5 changed files with 72 additions and 12 deletions

View File

@ -5,12 +5,12 @@ Returns the `n` maximum elements from the provided array. If `n` is greater than
Sort's the array's shallow copy in descending order and returns the first n elements
Skip the second argument to get a single element(in the form of a array)
``` js
```js
const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
```
``` js
maxN([1,2,3]); // [3]
maxN([1,2,3],2); // [3,2]
maxN([1,2,3],4); // [3,2,1]
```js
maxN([1, 2, 3]); // [3]
maxN([1, 2, 3], 2); // [3,2]
maxN([1, 2, 3], 4); // [3,2,1]
```

View File

@ -5,12 +5,11 @@ Returns the `n` minimum elements from the provided array. If `n` is greater than
Sort's the array's shallow copy in ascending order and returns the first n elements
Skip the second argument to get a single element(in the form of a array)
``` js
```js
const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
```
``` js
minN([1,2,3]); // [1]
minN([1,2,3],2); // [1,2]
minN([1,2,3],4); // [1,2,3]
```js
minN([1, 2, 3]); // [1]
minN([1, 2, 3], 2); // [1,2]
minN([1, 2, 3], 4); // [1,2,3]
```