Last active
April 2, 2018 17:59
-
-
Save RobAWilkinson/7aac685356f52c1c22eebe6ee066009c to your computer and use it in GitHub Desktop.
js-la-solution.js
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
function given(num) { | |
this.savedValue = num; | |
this.multiply = function(num) { | |
this.savedValue = this.savedValue * num | |
return this; | |
}; | |
this.divide = function(num) { | |
this.savedValue = this.savedValue / num | |
return this; | |
}; | |
this.subtract = function(num) { | |
this.savedValue -= num | |
return this; | |
}; | |
this.add = function(num) { | |
this.savedValue += num | |
return this; | |
}; | |
this.value = function() { | |
return this.savedValue | |
} | |
return this; | |
} | |
const num = given(10).multiply(5).add(6).divide(7).subtract(7).value() | |
assert(num == 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment