Question
Formatting variable numbers to display with commas
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, ",");
}
