Skip to content

Instantly share code, notes, and snippets.

@calvimor
Created September 20, 2016 14:37
Show Gist options
  • Save calvimor/0e354d287da465c86c30c1e3d313fe48 to your computer and use it in GitHub Desktop.
Save calvimor/0e354d287da465c86c30c1e3d313fe48 to your computer and use it in GitHub Desktop.
// Code goes here
var Calc = function (start) {
var that = this;
this.add = function(x) {
start = start + x;
return that;
};
this.multiply = function (x) {
start = start * x;
return that;
};
this.equals = function(callback) {
callback(start);
return that;
};
}
new Calc(0)
.add(1)
.add(2)
.multiply(3)
.multiply(2)
.equals(function (result) {
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment