I have a value 2000000 and i want this to be formatted as 2,000,000.00
below is the script i have tried but not able to get the exact output.
function myFunction() {
var num = 2000000;
var c = num.toLocaleString()
var n = num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
//var number=n.
var number = parseInt(n).toFixed(2);
document.getElementById("demo").innerHTML = n;
document.getElementById("demmo").innerHTML = number;
}
This function gives 2,000,000 and 2.00 but it should be 2,000,000.00 help me to get the required result.