-
-
Save marti1125/8276a73ae3ba50f0b7c9 to your computer and use it in GitHub Desktop.
get vowels and consonants
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// complete the function | |
function vowelsAndConsonants(s) { | |
for(var i = 0; i < s.length; i++){ | |
if( vowelTest(s[i]) ){ | |
console.log(s[i]) | |
} | |
} | |
for(var b = 0; b < s.length; b++){ | |
if( consonantsTest(s[b]) ){ | |
console.log(s[b]) | |
} | |
} | |
} | |
function vowelTest(s) { | |
return (/^[aeiou]$/i).test(s); | |
} | |
function consonantsTest(s) { | |
return (/(?=[a-z])[^aeiou]/i).test(s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment