JS II : Loop <Whale Talk Project>

Hi! I just finished the whale talk project, I just have to clarify on this if somebody can help me out I’d really appreciate it.

This is what I came up with (had to watch the walkthrough video):

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

for (i = 0; i < input.length; i++) {
  for (j = 0; j < vowels.length; j++) {
    if (input[i] === vowels[j]) {
      if (input[i] === 'e') {
      } else if (input[i] === 'u') {
      } else {

The question I have is that: are all the consonants from the variable input gone because (input[i] !== vowels[j]) is undefined, and is simply falsy? (There is no ‘else’ conditional for the first ‘if’.)
Just wanted to clarify! Thank you.


Indeed, no consonant will ever be considered because they do not match the condition of your first if – and you’ve not given them any alternative.

You could try specifying an else condition, just to check the result.

1 Like

Thank you so much! :smiley: