Whale Talk Exercise - Learn Javascript (Loops) - I don't know where to go from here

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:

  1. There are no consonants. Only vowels excluding “y”.
  2. The u ‘s and e ‘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’) {
} else if (input[i] === ‘uu’) {

You’re missing a let in: for (vowel = 0; vowel < vowels.length; vowel++) {

Also, you should only check if there is a single e for pushing ee, and a single u for adding uu


if (input[i] === 'ee') {
should be
if (input[i] === 'e') {
and so on …

Finally, you probably need to put an else statement after the else if block so that the loop still adds the letter (just one) when its a vowel other than e or u

Next time, please use the </> to have a place for a formatted version of your code before pasting it in.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.