Skip to content

Instantly share code, notes, and snippets.

@FranciscoG
Created August 5, 2015 21:35
Show Gist options
  • Save FranciscoG/952e7c10a71d08603009 to your computer and use it in GitHub Desktop.
Save FranciscoG/952e7c10a71d08603009 to your computer and use it in GitHub Desktop.
used to decode reversed matched strings
(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