How to count vowels in a string with TypeScript

1 Answer

0 votes
function vowel_count(str : string) : number {
  	const vowels = /[aeiou]/gi;
  	const result = str.match(vowels);
  	const count = result.length;
     
  	return count;
}
  
console.log(vowel_count("typescript programming"));
    
    
      
      
/*
run:
  
5
      
*/

 



answered May 12, 2022 by avibootz

Related questions

1 answer 223 views
1 answer 255 views
1 answer 233 views
2 answers 284 views
1 answer 255 views
255 views asked Jul 26, 2020 by avibootz
1 answer 254 views
...