Created
September 20, 2016 14:37
-
-
Save calvimor/0e354d287da465c86c30c1e3d313fe48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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