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// BEST and FASTER implementation using regex
2const countVowels = (str) => (str.match(/[aeiou]/gi) || []).length