update snippets 78 - 96
This commit is contained in:
@ -7,5 +7,8 @@ Use `Array.reduce()` to convert the filtered/picked keys back to an object with
|
||||
```js
|
||||
const pick = (obj, arr) =>
|
||||
arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {});
|
||||
// pick({ 'a': 1, 'b': '2', 'c': 3 }, ['a', 'c']) -> { 'a': 1, 'c': 3 }
|
||||
```
|
||||
|
||||
```js
|
||||
pick({ 'a': 1, 'b': '2', 'c': 3 }, ['a', 'c']) -> { 'a': 1, 'c': 3 }
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user