Skip to content

Instantly share code, notes, and snippets.

@cdiaz
Created March 17, 2016 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdiaz/61013102bcd0fefc51a7 to your computer and use it in GitHub Desktop.
Save cdiaz/61013102bcd0fefc51a7 to your computer and use it in GitHub Desktop.
Alien Translator Javascript
var dictionary = ['miel', 'extraterrestre', 'al', 'automovil', 'auto', 'revestir'];
var alienPattern = 'zyxwvutsrqponmlkjihgfedcba';
function ordenar_extraterrestre(alienPattern, dictionary){
var humanPattern = 'abcdefghijklmnopqrstuvwxyz';
var translation = [];
for (var i in dictionary) {
var humanWord = dictionary[i];
var alienWord = '';
for (var j in humanWord) {
alienWord += alienPattern.charAt(humanPattern.indexOf(humanWord[j]));
}
translation.push(alienWord);
}
return translation;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment