Update head.md
This commit is contained in:
@ -5,8 +5,7 @@ tags: array,beginner
|
||||
|
||||
Returns the head of a list.
|
||||
|
||||
Check if `arr` is truthy and has a `length` property, use `arr[0]` if possible
|
||||
to return the first element, otherwise return `undefined`
|
||||
Check if `arr` is truthy and has a `length` property, use `arr[0]` if possible to return the first element, otherwise return `undefined`.
|
||||
|
||||
```js
|
||||
const head = arr => (arr && arr.length ? arr[0] : undefined);
|
||||
|
||||
Reference in New Issue
Block a user