xxxxxxxxxx
using System.Linq;
public class Program
{
public static int CountVowels(string str)
=> str.Count(a=>$"aeiouAEIOU".Contains(a));
}
xxxxxxxxxx
// Write a function that returns the number of vowels found within a string.
// Vowel characters are 'a', 'e', 'i', 'o', and 'u'.
// Make sure the function is case insensitive!
// --- Examples
// vowels('What') --> 1
// vowels('Why?') --> 0
// vowels('aEiOu') --> 5
// vowels('I am a world-class developer using iterations') --> 16
function vowels(str) {
const vowel =['a','e' ,'o' , 'u','i']
str= str.toLowerCase()
let count = 0;
for (let index = 0; index < str.length; index++) {
if(vowel.includes(str[index])){
count++
}
}
return count
}