[프로그래머스] 숨어있는 숫자의 덧셈 (2) - JS

Lenny·2023년 6월 28일

문제

풀이

function solution(my_string) {
    var answer = 0;
    
    const arr = my_string.split(/([a-z]|[A-Z])/).filter((item) => {
        return !isNaN(item);
    });
    
    arr.forEach((item) => {
        answer += Number(item);
    })
    
    return answer;
}

profile
🧑‍💻

0개의 댓글