function countNumberOfEachVowelInString(s) {
const vowels = "aeiou";
const countVowels = new Map();
for (const ch of vowels) {
countVowels.set(ch, 0);
}
return countVowels;
}
const s = "python c c++ c# java php javascript";
const countVowels = countNumberOfEachVowelInString(s);
for (const ch of s) {
if (countVowels.has(ch)) {
countVowels.set(ch, countVowels.get(ch) + 1);
}
}
console.log(countVowels);
/*
run:
Map(5) { 'a' => 4, 'e' => 0, 'i' => 1, 'o' => 1, 'u' => 0 }
*/