Where's the mistake in taking the element in the line?



  • Hello.

    Objective Repeat the number of data in the line

    Here's my code.

    function getCount(str) {
      var vowelsCount = 0;
      var vowels = ['a', 'e', 'i', 'o', 'u'];
    

    var modernStr = str.split('');

    for (var i = 0; i < modernStr.length; ++i) {
        if(modernStr.includes(vowels[i])) vowelsCount++
    }
    

    return vowelsCount;
    }

    getCount('aviiiiiii')

    But he doesn't work, I can't understand why
    I'll be grateful for your help.



  • You're wrong. ifThat's right.

    if(vowels.includes(modernStr[i])) vowelsCount++
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2