I am trying to sort this array by its the number of its vowels using sort() callback function.
So far, i have my function to get the number of vowels but don't know how to implement it in sort() as a callback.
var array = [
"abc",
"december",
"ax",
"cv",
"veeeeee",
"colo",
"bobola",
"lax",
"cri",
"nahamua",
"pip"
];
Here is my function to get number of vowels in a word.
function isVowel(x) {
var result;
result = x.toLowerCase() == "a" || x == "e" || x == "i" || x == "o" || x == "u";
return result;
}
function countVowels(strChar) {
var token = strChar.split('') // array of words
var countVowel = token.filter(isVowel)
return 'number of vowels: ' + countVowel.length
}