function countNumberOfEachVowelInString(s: string) {
const vowels: string = "aeiou";
const countVowels: Map<any, any> = new Map();
for (const ch of vowels) {
countVowels.set(ch, 0);
}
return countVowels;
}
const s: string = "python c c++ c# java php javascript typescript";
const countVowels: Map<any, any> = 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" => 1, "i" => 2, "o" => 1, "u" => 0}
*/