Travis build: 1081
This commit is contained in:
32
README.md
32
README.md
@ -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
@ -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'
|
||||
```
|
||||
|
||||
@ -93,6 +93,7 @@ join:array
|
||||
JSONToFile:node,json
|
||||
last:array
|
||||
lcm:math,recursion
|
||||
longestItem:uncategorized
|
||||
lowercaseKeys:object
|
||||
luhnCheck:math,utility
|
||||
mapObject:array,object
|
||||
|
||||
Reference in New Issue
Block a user