Created
March 17, 2016 08:42
-
-
Save cdiaz/61013102bcd0fefc51a7 to your computer and use it in GitHub Desktop.
Alien Translator Javascript
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 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