Whale Talk - scope issue?

Not sure why I have an extra “E” in my output ??

const input = 'a whale of a deal!';

const vowels = ['a', 'e', 'i', 'o', 'u'];
let resultArray = [];

for (let i = 0; i < input.length; i++) {
  // console.log('i is '+ i);
  for (let vowel = 0; vowel < vowels.length; vowel++) {
    // console.log('x is '+ x);
    if (input[i] === vowels[vowel]) {

      if (input[i] === 'e') {
        resultArray.push('ee');
      }
      if (input[i] === 'u') {
        resultArray.push('uu');
      } else {
        resultArray.push(input[i])
      }
    }
  }
}
console.log(resultArray.join('').toUpperCase());

if we walk through your code, you push two e's here:

if (input[i] === 'e') {
        resultArray.push('ee');
      }

then if (input[i] === 'u') is false, so the else clause runs, pushing another e to your results array.