grefel
3/16/2016 - 1:33 PM

Pad a number

Pad a number

function pad (number, length, fill) { 
	if (fill === undefined) fill = "0";
	var str = '' + number;
	while (str.length < length) {
		str = fill + str;
	}
	return str;
}