Created
December 15, 2018 17:40
-
-
Save neatshell/dab83830be308879f04eb2bb7d815aba to your computer and use it in GitHub Desktop.
This file contains 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
// Swap keys with values of a javascript object | |
const swapKV = (object) => { | |
const ret = {}; | |
for (let key in object) { | |
if (object.hasOwnProperty(key)) { | |
ret[object[key]] = key; | |
} | |
} | |
return ret; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment