Answers for "javascript function to count the number of vowels in a given string"

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
1

find vowel & consonants in a string java script

const str = "The quick brown fox jumps over a lazy dog"; 
const vowels = str.match(/[aeiou]/gi); 
const consonants = str.match(/[^aeiou]/gi);   
vowels.concat([''],consonants).forEach(k => { console.log(k); } );
Posted by: Guest on October-09-2020
1

how to make a vowel counter in javascript

const vowelCount = str => {
  let vowels = /[aeiou]/gi;
  let result = str.match(vowels);
  let count = result.length;

  console.log(count);
};
Posted by: Guest on April-08-2020
0

count vowels in a string javascript

// BEST and FASTER implementation using regex
const countVowels = (str) => (str.match(/[aeiou]/gi) || []).length
Posted by: Guest on August-17-2020
-1

find vowels in string javascript

var name = userInput[0];
    var count =0;
  	function findvowel(name)
    {
    	var vowel = ['a','e','i','o','u','A','E','I','O','U'];
      	for(i=0;i<name.length;i++)
      	{
      		if(vowel.includes(name[i]))
        	{
          		count++;
        	}
      	}
      	return count;
    }
    
  console.log(findvowel(name));
Posted by: Guest on December-06-2020

Code answers related to "javascript function to count the number of vowels in a given string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language