■ 프로그래밍/알고리즘
[JS] Vowel Count
hi_mj
2020. 11. 14. 00:47
www.codewars.com/kata/54ff3102c1bad923760001f3/train/javascript
[ 문제 ]
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.
[ 풀이 ]
2020.11.14 (5min)
function getCount(str) {
var vowelsCount = 0;
for (n in str) {
if (str[n].includes('a') || str[n].includes('e') || str[n].includes('i') || str[n].includes('o') || str[n].includes('u')) {
vowelsCount++;
}
}
return vowelsCount;
}