[자바스크립트로 구현한 알고리즘] Credit Card Mask

남양주개발자

·

2016. 9. 20. 15:34

728x90
반응형



Description:

Usually when you buy something, you're asked whether your credit card number, phone number or answer to your most secret question is still correct.

However, since someone could look over your shoulder, you don't want that shown on your screen. Instead, we mask it. Your task is to write a function maskify, which changes all but the last four characters into '#'.

 

Examples

 

maskify("4556364607935616") == "############5616"

maskify( "64607935616") == "#######5616"

maskify( "1") == "1"

maskify( "") == ""

// "What was the name of your first pet?"

maskify("Skippy") == "##ippy"

maskify("Nananananananananananananananana Batman!") == "####################################man!"





아래는 개선된 코드입니다.




728x90
반응형
그리드형

이 포스팅은 쿠팡파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

💖 저자에게 암호화폐로 후원하기 💖

아이콘을 클릭하면 지갑 주소가자동으로 복사됩니다