-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVowelCount.js
More file actions
40 lines (39 loc) · 761 Bytes
/
Copy pathVowelCount.js
File metadata and controls
40 lines (39 loc) · 761 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
29
30
31
32
33
34
35
36
37
38
39
40
/**
*
* Description:
*
* Return the number (count) of vowels in the given string.
* We will consider a, e, i, o, u as vowels for this Kata (but not y).
* The input string will only consist of lower case letters and/or spaces.
*
* Kata URL: https://www.codewars.com/kata/54ff3102c1bad923760001f3
*
*
* @param {*} str
* @returns
*/
function getCount(str) {
let count = 0;
for (let i = 0; i < str.length; i++) {
switch (str[i].toLowerCase()) {
case "a":
count++;
break;
case "e":
count++;
break;
case "i":
count++;
break;
case "o":
count++;
break;
case "u":
count++;
break;
default:
break;
}
}
return count;
}