The objective is:
Take a phrase like ‘turpentine and turtles’ and translate it into its “whale talk” equivalent: ‘UUEEIEEAUUEE’.
There are a few simple rules for translating text to whale language:
- There are no consonants. Only vowels excluding “y”.
- The
u
‘s ande
‘s are extra long, so we must double them in our program.
And this is my code - i’m stuck at this point:
const input = ‘Free Willy the whale’;
const vowels = [‘a’,‘e’,‘i’,‘o’,‘u’];
let resultArray = ;
for (let i = 0; i < input.length; i++) {
console.log('I = ’ + input[i]);
for (vowel = 0; vowel < vowels.length; vowel++) {
console.log('vowel = ’ + vowel);
if (input[i] === vowels[vowel]) {
if (input[i] === ‘ee’) {
resultArray.push(‘ee’);
} else if (input[i] === ‘uu’) {
resultArray.push(‘uu’);
}
}
}
}
console.log(resultArray.join("").toUpperCase());