2022
009-핸드폰 번호 가리기 본문
function solution(phone_number) {
var answer = ''; // 가린 번호를 받을 빈 문자열
hide_number = phone_number.length-4; // 보여질 뒷 4자리 값을 뺀 길이
// *을 감춰야 하는 자릿수 만큼 반복하고 substring으로 뒷 4자리 반환
answer = ("*".repeat(hide_number)+phone_number.substring(hide_number));
return answer;
}
'코딩테스트 연습' 카테고리의 다른 글
011-x만큼 간격이 있는 n개의 숫자 (0) | 2022.05.15 |
---|---|
010-행렬의 덧셈 (0) | 2022.05.15 |
008-평균 구하기 (0) | 2022.05.14 |
007-음양 더하기 (0) | 2022.05.14 |
006-없는 숫자 더하기 (0) | 2022.05.14 |
Comments