I am trying to change the styling of numbers.
Try something like this.
const numberWithSep = (x) => {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "");
}
var num = numberWithSep('12345678');
document.getElementById("number").innerHTML = num;
//retrive like this
console.log(document.getElementById("number").innerText);
.sep {
display: inline-block;
padding: 10px;
}
If you want the separator as comma (,) just change the div
to ,