Travis build: 802 [ci skip]

This commit is contained in:
Travis CI
2018-01-01 16:45:34 +00:00
parent 6293796ef2
commit e3f75a55e9
6 changed files with 132 additions and 8 deletions

View File

@ -5,9 +5,13 @@ Inverts the key-value pairs of an object, without mutating it.
Use `Object.keys()` and `Array.reduce()` to invert the key-value pairs of an object.
```js
const invertKeyValues = obj => Object.keys(obj).reduce((acc,key) => { acc[obj[key]] = key; return acc;},{});
const invertKeyValues = obj =>
Object.keys(obj).reduce((acc, key) => {
acc[obj[key]] = key;
return acc;
}, {});
```
```js
invertKeyValues({name:'John', age: 20}) // { 20: 'age', John: 'name' }
invertKeyValues({ name: 'John', age: 20 }); // { 20: 'age', John: 'name' }
```