Here we demonstrate masking all digits of credit card
number except last four using padStart().
secondly we will add '...' to 'Read More' at the end u
sing padEnd()
Code:
var cc ="1234567867897890"
var lastFour = cc.slice(-4)
var length = cc.length
console.log(length)
console.log(lastFour)
var masked = lastFour.padStart(length,"*")
console.log(masked)//**** **** **** 7890
var str ="Read More"
var newlength = str.length + 3
var newstr = str.padEnd(newlength,'.')
console.log(newstr)//Read More...
Output:
16
7890
************7890
Read More...
No comments:
Post a Comment