1const vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'];
2
3function countVowels(sentence) {
4 let counts = 0;
5 for(let i = 0; i < vowels.length; i++) {
6 if(vowels.includes(sentence[i])) {
7 counts++;
8 }
9 }
10 return console.log(counts);
11}
12
13countVowels('Hello World');
14countVowels('AaEeIiOoUu');
15countVowels('aaaaa');
1const vowelCount = str => {
2 let vowels = /[aeiou]/gi;
3 let result = str.match(vowels);
4 let count = result.length;
5
6 console.log(count);
7};
1const str = "The quick brown fox jumps over a lazy dog";
2const vowels = str.match(/[aeiou]/gi);
3const consonants = str.match(/[^aeiou]/gi);
4vowels.concat([''],consonants).forEach(k => { console.log(k); } );
5
1function getCount(str) {
2let vowelList = 'AEIOUaeiou'
3let vowelsCount = 0;
4
5 for(var i = 0; i < str.length ; i++)
6 {
7 if (vowelList.indexOf(str[i]) !== -1)
8 {
9 vowelsCount += 1;
10 }
11 }
12 return vowelsCount;
13}
14
1 var name = userInput[0];
2 var count =0;
3 function findvowel(name)
4 {
5 var vowel = ['a','e','i','o','u','A','E','I','O','U'];
6 for(i=0;i<name.length;i++)
7 {
8 if(vowel.includes(name[i]))
9 {
10 count++;
11 }
12 }
13 return count;
14 }
15
16 console.log(findvowel(name));