-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvowelCounting.js
36 lines (34 loc) · 901 Bytes
/
vowelCounting.js
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
29
30
31
32
33
34
35
36
const readline = require('readline-sync');
exports.vowel = function performOneVowelCountingCalculation(){
console.log("Please enter a string to be evaluated:");
var stringTC = readline.prompt();
stringTC = stringTC.toLowerCase();
var vowelCount = {
'Acount': a=0,
'Ecount': e=0,
'Icount': i=0,
'Ocount': o=0,
'Ucount': u=0
};
for (x=0; x< stringTC.length; x++ ){
if(stringTC[x]==='a'){
vowelCount.Acount++
}
else if(stringTC[x]==='e'){
vowelCount.Ecount++
}
else if(stringTC[x]==='i'){
vowelCount.Icount++
}
else if(stringTC[x]==='o'){
vowelCount.Ocount++
}
else if(stringTC[x]==='u'){
vowelCount.Ucount++
}
else{
continue;
}
}
console.log(vowelCount);
}