Apply new format to snippets and template
This commit is contained in:
@ -5,8 +5,8 @@ tags: object,array,function,intermediate
|
||||
|
||||
Creates an object composed of the properties the given function returns truthy for. The function is invoked with two arguments: (value, key).
|
||||
|
||||
Use `Object.keys(obj)` and `Array.prototype.filter()`to remove the keys for which `fn` returns a falsy value.
|
||||
Use `Array.prototype.reduce()` to convert the filtered keys back to an object with the corresponding key-value pairs.
|
||||
- Use `Object.keys(obj)` and `Array.prototype.filter()`to remove the keys for which `fn` returns a falsy value.
|
||||
- Use `Array.prototype.reduce()` to convert the filtered keys back to an object with the corresponding key-value pairs.
|
||||
|
||||
```js
|
||||
const pickBy = (obj, fn) =>
|
||||
@ -17,4 +17,4 @@ const pickBy = (obj, fn) =>
|
||||
|
||||
```js
|
||||
pickBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'); // { 'a': 1, 'c': 3 }
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user