Skip to content

Instantly share code, notes, and snippets.

@EricHech
Created January 6, 2019 04:48
Show Gist options
  • Save EricHech/c8f33ffae394559593950b67415af847 to your computer and use it in GitHub Desktop.
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.
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