Level1 - 숫자 문자열과 영단어

손대중·2022년 3월 14일
0

문제 설명 및 링크

프로그래머스 - 숫자 문자열과 영단어

나의 풀이

풀이라고 할 것도 없이 그냥 문제에 나온 알고리즘대로 코딩하면 됨.

코드

모든 프로그래머스 문제 관련 코드들은 GitHub 링크 에 있음.

function solution(s) {
    const num = s.replace(/zero/g, '0')
        .replace(/one/g, '1')
        .replace(/two/g, '2')
        .replace(/three/g, '3')
        .replace(/four/g, '4')
        .replace(/five/g, '5')
        .replace(/six/g, '6')
        .replace(/seven/g, '7')
        .replace(/eight/g, '8')
        .replace(/nine/g, '9');
    
    return Number(num);
}

0개의 댓글