-
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathcheck-vowel-char.js
More file actions
28 lines (28 loc) · 757 Bytes
/
check-vowel-char.js
File metadata and controls
28 lines (28 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function hitungAlphabet(str) {
str = str.toUpperCase()
const vokal = 'AIUEO';
const konsonan = 'BCDFGHJKLMNPQRSTVWXYZ';
const arrVokal =[];
const arrKonsonan=[];
for(let i =0;i<str.length;i++){
for(let j = 0 ; j<konsonan.length;j++){
if(str[i] == konsonan[j]){
arrKonsonan.push(str[i])
}
}
for(let k = 0 ; k<vokal.length;k++){
if(str[i] == vokal[k]){
arrVokal.push(str[i])
}
}
}
const result = {
huruf: {
vokal: arrVokal.length,
konsonan: arrKonsonan.length
},
panjang: str.length
}
return result
}
console.log(hitungAlphabet("Halo Semua Aku @#$%rLifan"));