Over a million developers have joined DZone.

Comma Numbers

·


function comma(number) { // oh dear god...
	str = new String(number);
	var val = new String();
	var num = str.length % 3;
	if (num == 0) { num = 3; }
	while (str.length > 0) {
		val += str.substring (0, num) + ",";
		str = str.substring (num);
		num = 3;
	}
	return val.substring (0, val.length - 1);
}
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}