Travis build: 1081

This commit is contained in:
30secondsofcode
2018-01-08 20:01:19 +00:00
parent 7ebbe5936b
commit f7484d30cc
4 changed files with 44 additions and 5 deletions

View File

@ -339,6 +339,15 @@ average(1, 2, 3);
</details>
### _Uncategorized_
<details>
<summary>View contents</summary>
* [`longestItem`](#longestitem)
</details>
---
## 🔌 Adapter
@ -5257,6 +5266,29 @@ yesNo('Foo', true); // true
<br>[⬆ Back to top](#table-of-contents)
---
## _Uncategorized_
### longestItem
Takes any number of iterable objects or objects with a `length` property and returns the longest one.
Use `Array.sort()` to sort all arguments by `length`, return the first (longest) one.
```js
const longestItem = (...vals) => [...vals].sort((a, b) => b.length - a.length)[0];
```
```js
longestItem('this', 'is', 'a', 'testcase'); // 'testcase'
longestItem(...['a', 'ab', 'abc']); // 'abc'
longestItem(...['a', 'ab', 'abc'], 'abcd'); // 'abcd'
longestItem([1, 2, 3], [1, 2], [1, 2, 3, 4, 5]); // [1, 2, 3, 4, 5]
longestItem([1, 2, 3], 'foobar'); // 'foobar'
```
<br>[⬆ back to top](#table-of-contents)
## Collaborators

File diff suppressed because one or more lines are too long

View File

@ -9,9 +9,9 @@ const longestItem = (...vals) => [...vals].sort((a, b) => b.length - a.length)[0
```
```js
longestItem ('this', 'is', 'a', 'testcase'); // 'testcase'
longestItem (...['a', 'ab', 'abc']); // 'abc'
longestItem (...['a', 'ab', 'abc'], 'abcd'); // 'abcd'
longestItem('this', 'is', 'a', 'testcase'); // 'testcase'
longestItem(...['a', 'ab', 'abc']); // 'abc'
longestItem(...['a', 'ab', 'abc'], 'abcd'); // 'abcd'
longestItem([1, 2, 3], [1, 2], [1, 2, 3, 4, 5]); // [1, 2, 3, 4, 5]
longestItem([1, 2, 3], 'foobar'); // 'foobar'
```

View File

@ -93,6 +93,7 @@ join:array
JSONToFile:node,json
last:array
lcm:math,recursion
longestItem:uncategorized
lowercaseKeys:object
luhnCheck:math,utility
mapObject:array,object