const str = "The quick brown fox jumps over a lazy dog";
const vowels = str.match(/[aeiou]/gi);
const consonants = str.match(/[^aeiou]/gi);
vowels.concat([''],consonants).forEach(k => { console.log(k); } );
// check the word is vowel or not
let words = "aeiou";
let newWords = "";
function isVowelOrNot(words) {
for (let word of words) {
if (
word === "a" ||
word === "e" ||
word === "i" ||
word === "o" ||
word === "u"
) {
newWords = newWords + word;
}
}
if (newWords === words) {
return true;
} else {
return false;
}
}
let result = isVowelOrNot(words);
console.log(result);
const encode = (string) => {
let newStringArray =string.split("").filter(
(ch) => ch === "a" || ch === "e" || ch === "i" || ch === "o" || ch === "u"
);
return newStringArray;
};
encode('football').forEach(vowel=>{
console.log(vowel);
})
//o
//o
//a