const numb= 3436547568768345; function separator(numb) { var str = numb.toString().split("."); str[0] = str[0].replace(/B(?=(d{3})+(?!d))/g, ","); return str.join("."); } console.log(separator(numb))