function that returns the value of a number like 6k will be 6000
function thousands_with_commas(x) { var parts = x.toString().split("."); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return parts.join("."); } thousands_with_commas(1000);