Find no. of vowels(a,e,i,o,u) in a string

Hi there 👋, I am Anil Verma I am a passionate Full Stack Web Developer who is fascinated by complex engineering problems.
(Javascript)
*ex. →vowelsCount(‘*hi there*’) → 3*
### Sol. 1
vowelsCount = (str) => {
let count = 0;
for (let char of str) {
if (‘aeiou’.includes(char.toLowerCase())) {
count++
}
}
console.log(count)
return count;
}
vowelsCount(‘hi there’)
Sol. 2
vowelsCount = (str) => {
let count = 0;
const matchedArray = str.match(/\[aeiou\]/gi);
if (matchedArray) {
count = matchedArray.length;
}
return count
}
console.log(vowelsCount(‘hi there’))

Happing Coding… 👏👏

