Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update this.total when a digit is added

  • Loading branch information...
commit 4c553924706c76e95b7a6d1b9f399d6f147476fc 1 parent e7a6d18
@danzajdband danzajdband authored
Showing with 2 additions and 1 deletion.
  1. +2 −1  index.js
View
3  index.js
@@ -62,6 +62,7 @@ Counter.prototype.ensureDigits = function(n){
while (this._digits.length < n) {
this.addDigit();
}
+ this.total = n;
};
/**
@@ -99,11 +100,11 @@ 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;
this.ensureDigits(len);
+ var digits = this.total;
for (var i = 0; i < len; ++i) {
this.updateDigit(digits - i - 1, str[len - i - 1]);
Please sign in to comment.
Something went wrong with that request. Please try again.