Copy link to clipboard
Copied
I have created some variables with large numbers and making calculations with them. These variable are displaying in my course but are unformatted with commas. I know this can be down with math functions in javascript but need help.
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
Copy link to clipboard
Copied
You are going to need to put the function I gave you in the HTML page in the head section just above the:
function initializeCP()
In the JS window you can add the variables together as an argument for the function:
var result = numberWithCommas(window.variable_1+window.variable_2);
window.yourFinalVariable = result;