Hello reader's!
On a given number format if you want it to be customize like a figure with separated by (,)
like 128,347,556. By using a function and in the function we will Preg Match the string with every hundreds and thousands
You can use the code below :-
function NumberToChange (youNumber) {
return youNumber.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}
print(NumberToChange(3675));
Output: 3,675
print(NumberToChange(589854));
Output: 589,854
print(NumberToChange(666656668));
Output: 666,656,668
0 Comment(s)