[프로그래머스] 모음 제거

butterbeetle·2023년 1월 27일
0

코딩테스트

목록 보기
20/132
post-thumbnail

문제설명

영어에선 a, e, i, o, u 다섯 가지 알파벳을 모음으로 분류합니다. 문자열 my_string이 매개변수로 주어질 때 모음을 제거한 문자열을 return하도록 solution 함수를 완성해주세요.

제한사항

  • my_string은 소문자와 공백으로 이루어져 있습니다.
  • 1 ≤ my_string의 길이 ≤ 1,000

입출력 예

my_stringresult
"bus""bs"
"nice to meet you""nc t mt y"

내 풀이

function solution(my_string) {
    const vowels = ["a","e","i","o","u"]    
    return [...my_string].filter((item)=>{
        if(!vowels.includes(item)) return item
    }).join('')
}
profile
멍청이

0개의 댓글