JSFiddle - React, Tailwind, and code Playground

JavaScript

function formatMoney(number) {
	    number = parseFloat(number.toString().match(/^-?\d+\.?\d{0,2}/));
	    //Seperates the components of the number
	    var components = (Math.floor(number * 100) / 100).toString().split(".");
	    //Comma-fies the first part
	    components [0] = components [0].replace(/\B(?=(\d{3})+(?!\d))/g, ",").toFixed();
	    //Combines the two sections
	    return components.join(".");
	}
alert(formatMoney(-1112223.3));