File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Step By Step
2
+ function VowelCount ( str ) {
3
+ // First, we Remove all characters in the string that aren't vowels with the .replace method.
4
+ // Note that ^ in Regex means "all characters not in the set", so placing it in front of aeiou means "Match everything that isn't a vowel"
5
+ // Enclosing a set in [] means that our string matches any individual character in that set
6
+ // Ending with our /g tag signifies that we want to do a global search and lets our engine know to going through the entire string.
7
+ str = str . replace ( / [ ^ a e i u o ] / g, '' ) ;
8
+
9
+ // Finally, we return the length of the string to "count" how many vowels are left.
10
+ return str . length ;
11
+ }
12
+
13
+
14
+ // No Comments
15
+ function VowelCount ( str ) {
16
+ return str . replace ( / [ ^ a e i o u ] / g, '' ) . length ;
17
+ }
You can’t perform that action at this time.
0 commit comments