Answers for "Write a program to count the number of vowels into the string js"

4

count vowels in javascript

const vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'];

function countVowels(sentence) {
  let counts = 0;
  for(let i = 0; i < vowels.length; i++) {
    if(vowels.includes(sentence[i])) {
      counts++;
    }
  }
  return console.log(counts);
}

countVowels('Hello World');
countVowels('AaEeIiOoUu');
countVowels('aaaaa');
Posted by: Guest on July-24-2020
0

vowels Count js

function getCount(str) {
  return (str.match(/[aeiou]/ig)||[]).length;
}
Posted by: Guest on July-23-2021

Code answers related to "Write a program to count the number of vowels into the string js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language