Update longestItem.md

This commit is contained in:
Angelos Chalaris
2018-10-25 13:24:26 +03:00
committed by GitHub
parent e0c7d41271
commit c7336809f7

View File

@ -7,8 +7,8 @@ Returns `undefined` if no arguments are provided.
Use `Array.prototype.reduce()`, comparing the `length` of objects to find the longest one.
```js
const longestItem = (...args) =>
args.reduce((a, x) => (x.length > a.length ? x : a));
const longestItem = (...vals) =>
vals.reduce((a, x) => (x.length > a.length ? x : a));
```
```js