Skip to content

Instantly share code, notes, and snippets.

@RobAWilkinson
Last active April 2, 2018 17:59
Show Gist options
  • Save RobAWilkinson/7aac685356f52c1c22eebe6ee066009c to your computer and use it in GitHub Desktop.
Save RobAWilkinson/7aac685356f52c1c22eebe6ee066009c to your computer and use it in GitHub Desktop.
js-la-solution.js
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