https://programmers.co.kr/learn/courses/30/lessons/12948
function solution(phone_number) {
var answer = '';
var len = phone_number.length;
for(var i =0; i<len; i++ ){
if(i < len-4){
answer = answer + '*';
} else {
answer = answer + phone_number[i];
}
}
return answer;
}
정규식&replace(), repeat()&slice()... 등등 다른 method들을 사용한 방법을 생각해볼 것.
function solution(phone_number) {
var answer = '';
var lengthOfPhoneNumber = phone_number.length;
console.log(lengthOfPhoneNumber);
for (var i=0; i<lengthOfPhoneNumber; i++){
if (i<lengthOfPhoneNumber - 4){
answer = answer + '*';
} else {
answer = answer + phone_number[i];
}
}
return answer;
}
#정규식의 활용