Skip to content

Commit 8dda4ac

Browse files
committed
updated objects.js file -- pair programming
1 parent 354a31c commit 8dda4ac

3 files changed

Lines changed: 37 additions & 10 deletions

File tree

‎package-lock.json‎

Lines changed: 29 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"babel-jest": "^19.0.0",
2222
"eslint": "^3.17.1",
2323
"eslint-config-airbnb-base": "^11.1.3",
24-
"eslint-plugin-import": "^2.2.0",
24+
"eslint-plugin-import": "^2.8.0",
2525
"jest": "^19.0.2",
2626
"regenerator-runtime": "^0.10.3"
2727
},

‎src/objects.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ const invert = (obj) => {
3232
// Returns a copy of the object where the keys have become the values and the values the keys.
3333
// Assume that all of the object's values will be unique and string serializable.
3434
// http://underscorejs.org/#invert
35+
const newObj = {};
36+
const objKeys = Object.keys(obj);
37+
const objVal = Object.values(obj);
38+
for (let i = 0; i < objVal.length; i++) {
39+
newObj[objVal[i]] = objKeys[i];
40+
}
41+
return newObj;
3542
};
3643

3744
const defaults = (obj, defaultProps) => {

0 commit comments

Comments
 (0)