var counter = 1; var scrap = counter; document.write(''); for (var i = 3; i >= 1; i--) { var divisor = Math.pow(10, i - 1); var remainder = counter % divisor; var digit = ((scrap - remainder) / divisor); document.write('' + digit + ''); scrap = remainder; } document.write('');