Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var User = function() {
- ...
- }
- var Pie = function() {
- return {
- _filling: null,
- getFilling: function() {
- return this._filling;
- },
- setFilling: function(filling) {
- this._filling = filling;
- if (!this._isFillingAcceptable(filling)) {
- User.delete();
- console.log('your account has been deleted');
- }
- },
- _isFillingAcceptable: function(filling) {
- return (typeof filling === 'String' && filling.toLowerCase() === 'apple');
- }
- };
- };
- // make the pie
- var pieOne = new Pie();
- // fill the pie
- pieOne.setFilling('apple');
- // what's in the pie?
- console.log(pieOne.getFilling()); // apple
- // make another pie
- var pieTwo = new Pie();
- // fill the pie
- pieTwo.setFilling('steak');
- // console.log('your account has been deleted');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement