Created
July 17, 2014 14:23
-
-
Save roadmapper/9ac28c06cb377ec2bf9d to your computer and use it in GitHub Desktop.
Creates a reverse map in Javascript - source: http://stackoverflow.com/questions/10974493/javascript-quickly-lookup-value-in-object-like-we-can-with-properties
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
var map = { | |
"s":"d", "m":"e", | |
"e":"h", "x":"l", | |
"z":"o", "i":"r", | |
"a":"w", "o":"!", | |
"-":" " | |
}, | |
reverseMap = {} | |
for (j in map){ | |
if (!Object.prototype.hasOwnProperty.call(map, j)) continue | |
reverseMap[map[j]] = j | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment