Travis build: 1194

This commit is contained in:
30secondsofcode
2018-01-11 18:34:38 +00:00
parent beda1ea589
commit 3414134ee7
5 changed files with 91 additions and 6 deletions

View File

@ -7,9 +7,12 @@ Use `Array.reduce()` to create a new object with the same values and mapped keys
```js
const mapKeys = (obj, fn) =>
Object.keys(obj).reduce((acc,k) => {acc[fn(obj[k], k, obj)] = obj[k]; return acc;},{});
Object.keys(obj).reduce((acc, k) => {
acc[fn(obj[k], k, obj)] = obj[k];
return acc;
}, {});
```
```js
mapKeys({ 'a': 1, 'b': 2 }, (val, key) => key + val); // { a1: 1, b2: 2 }
mapKeys({ a: 1, b: 2 }, (val, key) => key + val); // { a1: 1, b2: 2 }
```