아래의 코드는 숫자 자료형에 replace함수를 적용하기 때문에 에러가 발생합니다.
const num = 010-1234-1234;
const result = num.replace(/-/g, '');
replace 함수는 문자열에 대해서 적용이 가능한 함수이기 때문에 toString()
함수를 이용해서 먼저 문자열로 바꿔줘야 합니다.
const num = 010-1234-1234;
const result = num.toString.replace(/-/g, '');