Skip to content

Instantly share code, notes, and snippets.

@debonx
Created August 13, 2019 17:53
Show Gist options
  • Save debonx/043f87e24bc0f83de9e22ad6b2196003 to your computer and use it in GitHub Desktop.
Save debonx/043f87e24bc0f83de9e22ad6b2196003 to your computer and use it in GitHub Desktop.
Example of converting regular sentences into whale language.
let input = 'Mi chiedi qual è stato il mio progresso? Ho cominciato a essere amico di me stesso.';
const vowels = ['a', 'e', 'i', 'o', 'u'];
let resultArray = [];
for(i = 0; i < input.length; i++){
//console.log(i);
for(j = 0; j < vowels.length; j++){
if(input[i] === vowels[j]) {
if(vowels[j] === 'e' || vowels[j] === 'u') {
resultArray.push(vowels[j] + vowels[j]);
} else {
resultArray.push(vowels[j]);
}
}
}
}
console.log(resultArray.join('').toUpperCase());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment