count vocals
function hitungVokal(kalimat){
const vokal = "aiueo";
const hasil = {};
kalimat = kalimat.toLowerCase();
for (let huruf of kalimat){
if(vokal.includes(huruf)){
if(hasil[huruf]){
hasil[huruf]++;
}else {
hasil[huruf] = 1;
}
}
}
return hasil;
kalimat = process.argv.slice(2).join(" ");
const hasilHitung = hitungVokal(kalimat);
console.log("kalimat : ", kalimat);
console.log("jumalah huruf vokal");
console.log("-------------------");
const totalVokal = Object.values(hasilHitung).reduce((total,count)=>total+count,00);
for(let huruf of "aiueo"){
const count = hasilHitung[huruf] || 0;
console.log(`${huruf.toUpperCase()} : $[count]`);
}
console.log("total:",totalVokal);
}
hitungVokal("halo");