[프로그래머스] 중복된 문자 제거

·2023년 2월 22일
0

프로그래머스_0단계

목록 보기
34/49

Q. 문자열 my_string이 매개변수로 주어집니다. my_string에서 중복된 문자를 제거하고 하나의 문자만 남긴 문자열을 return하도록 solution 함수를 완성해주세요.

내 풀이

function solution(my_string) {
    const arr = my_string.split('')
    const set = new Set(arr);
    const newArr = [...set];
    return newArr.join('')
}

다른 사람의 풀이

function solution(my_string) {
    return [...new Set(my_string)].join('');
}
profile
개발자가 되는 과정

0개의 댓글