Created
August 24, 2021 18:58
-
-
Save jeftarmascarenhas/2f647a2c37ead0bc102d43536da8b9b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firstString = '6' | |
console.log(firstString.padStart(4, '0')) | |
// result: "0006" | |
const creditCard = '09290201320409' | |
const getLast4Digits = (str) => str.slice(-4) | |
const maskedCreditCardNumber = getLast4Digits(creditCard).padStart(creditCard.length, '*') | |
console.log(maskedCreditCardNumber) | |
// maskedCreditCardNumber result: "**********0409" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment