JSFiddle - React, Tailwind, and code Playground

by wirey00

JavaScript

function ReplaceNumberWithCommas(yourNumber) {
    //Seperates the components of the number
    var components = yourNumber.toString().split(".");
    //Comma-fies the first part
    components [0] = components [0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    //Combines the two sections
    return components.join(".");
}

alert(ReplaceNumberWithCommas(1134343436.6696));