I\'m using basic JavaScript to count the number of vowels in a string. The below code works but I would like to have it cleaned up a bit. Would using .includes()
const containVowels = str => {
const helper = ['a', 'e', 'i', 'o', 'u'];
const hash = {};
for (let c of str) {
if (helper.indexOf(c) !== -1) {
if (hash[c]) {
hash[c]++;
} else {
hash[c] = 1;
}
}
}
let count = 0;
for (let k in hash) {
count += hash[k];
}
return count;
};
console.log(containVowels('aaaa'));