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;
}
'■ 프로그래밍 > 알고리즘' 카테고리의 다른 글
[JS] Format a string of names like 'Bart, Lisa & Maggie'. (0) | 2020.11.21 |
---|---|
[JS] Human Readable Time (0) | 2020.11.15 |
[JS] Stop gninnipS My sdroW! (0) | 2020.11.13 |
[JS] Regex validate PIN code (0) | 2020.11.12 |
[JS] Who likes it? (0) | 2020.11.11 |