just do it

영어가싫어요(프로그래머스, JavaScript) 본문

자료구조&알고리즘/코딩테스트

영어가싫어요(프로그래머스, JavaScript)

밍풀 2023. 1. 9. 21:11

 

1
2
3
4
5
6
7
8
9
10
11
function solution(numbers) {
    let arr =["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
    let b =numbers;
    for(let i=0; i<10; i++){
      while(b!==b.replace(arr[i],i)){
        b = b.replace(arr[i],i);
      }
    }
    console.log(b);
    return parseInt(b);
}
cs