DEV Community

Discussion on: Find The Vowels used in a String with JavaScript

Collapse
 
felipperegazio profile image
Felippe Regazio • Edited

Nice post! Also very important for beginners since you structured and explained very well. Good Job. If i had to do it, i would go with regex:

str.replace(/[^aeiou]/ig,'').length;

It just removes everything that is not a vowel and returns the new string size. The i tells it to be case insensitive.

Collapse
 
tadea profile image
Tadea Simunovic

Great advice! Thank you