Skip to content

Instantly share code, notes, and snippets.

@cferdinandi
Created July 5, 2023 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cferdinandi/7cfd240de490308b88b3207a54d06c3d to your computer and use it in GitHub Desktop.
Save cferdinandi/7cfd240de490308b88b3207a54d06c3d to your computer and use it in GitHub Desktop.
/**
* Constructor Pattern Boilerplate
*/
let MyLibrary = (function () {
/**
* Create the Constructor object
* @param {Number} start The starting amount
*/
function Constructor (start = 0) {
this.total = start;
}
/**
* Add money to the total
*/
Constructor.prototype.add = function (num = 1) {
this.total = this.total + num;
};
/**
* Remove money from the total
*/
Constructor.prototype.subtract = function (num = 1) {
this.total = this.total - num;
};
return Constructor;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment