π
Count Vowels
Count Vowelsμ¬μ λ¬Έμμ΄ +10pts
Problem
Write a function that counts the number of vowels (a, e, i, o, u) in a string.
Examples
Input:
countVowels("hello")Output:
2π‘ e, oκ° λͺ¨μ
Input:
countVowels("JavaScript")Output:
3Explanation
μ΄ λ¬Έμ λ **λ¬Έμμ΄ κ²μ**κ³Ό **λ°°μ΄ νν°λ§**μ κ²°ν©νμ¬ νΉμ λ¬Έμλ₯Ό μΈλ λ°©λ²μ νμ΅ν©λλ€. **μ λ΅: λͺ¨μ λͺ©λ‘ μ μ** λμλ¬Έμ λͺ¨λ λͺ¨μμ ν¬ν¨νλ λ¬Έμμ΄ `'aeiouAEIOU'`λ₯Ό λ§λλλ€. μ΄λ κ² νλ©΄ λμλ¬Έμλ₯Ό λ³λλ‘ μ²λ¦¬νμ§ μμλ λ©λλ€. **includes λ©μλ** `includes()`λ λ¬Έμμ΄μ΄λ λ°°μ΄μ νΉμ μμκ° μλμ§ νμΈν©λλ€: `'aeiouAEIOU'.includes('e')` β true `'aeiouAEIOU'.includes('x')` β false **μ²λ¦¬ κ³Όμ (μ: "hello...
View detailed explanation βKey Concepts
includes λ©μλ filter λ©μλ λ¬Έμμ΄ κ²μ λμλ¬Έμ μ²λ¦¬
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.