JSFiddle - React, Tailwind, and code Playground
JavaScript
function shortenNum(num){
if(num.length > 6){
var first = num.slice(0, 3);
var last = num.slice(-3);
//console.log(first + "..." + last );
alert(first + "..." + last );
} else {
alert(num)
}
}
// should return 112...899
shortenNum("112233445566778899");
shortenNum("19999");
shortenNum("3536355");