[Codewars#7kyu] - Vowel Count

jihye·2022년 6월 4일
0

알고리즘

목록 보기
6/12

문제

모음 수 구하기


풀이

function getCount(str) {
   // 정규 표현식으로 모음만 골라내기 
    let vowelsCount = str.trim().match(/[a,e,i,o,u]/gi); 
    // vowelsCount 가 null 이라면 모음이 없다는 뜻. 
    // 따라서 vowelsCount = null 이면 vowelsCount.length = 0,
    // 아니면 vowelsCount.legnth 보여주기
    return vowelsCount == null ?  0 : vowelsCount.length ;  
  }
profile
프론트엔드 개발자

0개의 댓글