Skip to content

Instantly share code, notes, and snippets.

@OscarGodson
Created January 24, 2012 16:37
Show Gist options
  • Save OscarGodson/e518c2676e8eb64fe268 to your computer and use it in GitHub Desktop.
Save OscarGodson/e518c2676e8eb64fe268 to your computer and use it in GitHub Desktop.
(function(window,undefined){
var Calc = function(){
this.sum = 0;
return this;
}
Calc.prototype.equals = function(){
return this.sum;
}
Calc.prototype.add = function(n){
this.sum = this.sum + n;
return this;
}
Calc.prototype.subtract = function(n){
this.sum = this.sum - n;
return this;
}
Calc.prototype.multiply = function(n){
this.sum = this.sum * n;
return this;
}
Calc.prototype.divide = function(n){
this.sum = this.sum / n;
return this;
}
window.Calc = Calc;
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment