Skip to content

Instantly share code, notes, and snippets.

@marti1125
Created February 29, 2016 12:57
Show Gist options
  • Save marti1125/8276a73ae3ba50f0b7c9 to your computer and use it in GitHub Desktop.
Save marti1125/8276a73ae3ba50f0b7c9 to your computer and use it in GitHub Desktop.
get vowels and consonants
// 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