Permalink
Browse files

Merge pull request #2 from danzajdband/master

Now it should work
  • Loading branch information...
tj committed Oct 18, 2012
2 parents 642f2d4 + 4893c79 commit 0a72e37a876f2a3d6f145d75648dd6ab3fbdc4fb
Showing with 2 additions and 3 deletions.
  1. +2 −3 index.js
View
@@ -99,14 +99,13 @@ Counter.prototype.updateDigit = function(i, val){
Counter.prototype.update = function(n){
this.n = n;
- var digits = this.total;
var str = n.toString();
var len = str.length;
+ var digits = Math.max(len, this.total);
this.ensureDigits(len);
-
for (var i = 0; i < len; ++i) {
- this.updateDigit(digits - i - 1, str[i]);
+ this.updateDigit(digits - i - 1, str[len - i - 1]);
}
return this;

0 comments on commit 0a72e37

Please sign in to comment.