Snippets

Kyle Martinez Format Number

Created by Kyle Martinez
1
2
3
4
5
function numberWithCommas(num) {
    var parts = num.toString().split(".");
    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    return parts.join(".");
}

Comments (0)