JSFiddle - React, Tailwind, and code Playground
by ananyaneogi
JavaScript
var str = '5026782019263';
var trailingCharsIntactCount = 4;
str = new Array(str.length - trailingCharsIntactCount + 1).join('x') + str.slice( -trailingCharsIntactCount);
console.log(str);