Skip to content

Instantly share code, notes, and snippets.

@danielchikaka
Created September 9, 2021 07:25
Show Gist options
  • Save danielchikaka/4663498941c58a56fd4a368bb2ea88b0 to your computer and use it in GitHub Desktop.
Save danielchikaka/4663498941c58a56fd4a368bb2ea88b0 to your computer and use it in GitHub Desktop.
function findVowelsConsonants(sentence) {
var arr = [];
var arrSentence = sentence.split('');
// Get all vowels
arrSentence.forEach(el => {
if(['a','e', 'i', 'o', 'u'].indexOf(el.toLowerCase()) !== -1){
arr.push(el);
}
} );
// Get all consonants
arrSentence.forEach(el => {
if(['a','e', 'i', 'o', 'u'].indexOf(el.toLowerCase()) === -1){
arr.push(el);
}
} );
// Publish
arr.forEach(el => console.log(el))
}
console.log(findVowelsConsonants('daniel'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment