Skip to content

Instantly share code, notes, and snippets.

@tigerclaw-az
Created December 16, 2013 22:46
Show Gist options
  • Save tigerclaw-az/7995905 to your computer and use it in GitHub Desktop.
Save tigerclaw-az/7995905 to your computer and use it in GitHub Desktop.
function tongues(code) {
var vowels = ['a', 'i', 'y', 'e', 'o', 'u'],
consonants = ['b', 'k', 'x', 'z', 'n', 'h', 'd', 'c', 'w', 'g', 'p', 'v', 'j', 'q', 't', 's', 'r', 'l', 'm', 'f'];
return code.split('').map(function(l) {
var v = vowels.indexOf(l.toLowerCase()),
c = consonants.indexOf(l.toLowerCase()),
letter = l;
if (v !== -1) {
letter = vowels[(v-3 < 0) ? ((v-3)+vowels.length)%vowels.length : v-3];
} else if (c !== -1) {
letter = consonants[(c-10 < 0) ? ((c-10)+consonants.length)%consonants.length : c-10];
}
if ((/[A-Z]/).test(l)) letter = letter.toUpperCase();
return letter;
}).join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment