Created
August 5, 2015 21:35
-
-
Save FranciscoG/952e7c10a71d08603009 to your computer and use it in GitHub Desktop.
used to decode reversed matched strings
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
(function(){ | |
function alphaInvert(str) { | |
var alpha = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; | |
var rev = alpha.slice().reverse(); // slice makes a copy of the array | |
var result = ""; | |
str.split("").forEach(function(val,i,r){ | |
result += rev[alpha.indexOf(val)]; // indexOf IE9+ | |
}); | |
return result; | |
} | |
window.alphaInvert = alphaInvert; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment