how to format int in js to have comma code example Example: how to format an integer with a comma in javascript x.toString().toLocaleString(); // x must be a number