Snippet format update
To match the starter (for the migration)
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
### invertKeyValues
|
||||
---
|
||||
title: invertKeyValues
|
||||
tags: object,function,intermediate
|
||||
---
|
||||
|
||||
Inverts the key-value pairs of an object, without mutating it. The corresponding inverted value of each inverted key is an array of keys responsible for generating the inverted value. If a function is supplied, it is applied to each inverted key.
|
||||
|
||||
@ -18,4 +21,4 @@ const invertKeyValues = (obj, fn) =>
|
||||
```js
|
||||
invertKeyValues({ a: 1, b: 2, c: 1 }); // { 1: [ 'a', 'c' ], 2: [ 'b' ] }
|
||||
invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value); // { group1: [ 'a', 'c' ], group2: [ 'b' ] }
|
||||
```
|
||||
```
|
||||
Reference in New Issue
Block a user