Created
January 6, 2019 04:48
-
-
Save EricHech/c8f33ffae394559593950b67415af847 to your computer and use it in GitHub Desktop.
Pass it an object and it will console.log a new object with the reverse key/val pairs added to it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createLUT = (obj) => { | |
const copy = { ...obj }; | |
Object.entries(copy).forEach((each) => (copy[each[1]] = each[0])); | |
console.log(JSON.stringify(copy)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment