Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. var User = function() {
  2. ...
  3. }
  4.  
  5. var Pie = function() {
  6.  
  7. return {
  8. _filling: null,
  9.  
  10. getFilling: function() {
  11. return this._filling;
  12. },
  13.  
  14. setFilling: function(filling) {
  15. this._filling = filling;
  16. if (!this._isFillingAcceptable(filling)) {
  17. User.delete();
  18. console.log('your account has been deleted');
  19. }
  20. },
  21.  
  22. _isFillingAcceptable: function(filling) {
  23. return (typeof filling === 'String' && filling.toLowerCase() === 'apple');
  24. }
  25.  
  26. };
  27.  
  28. };
  29.  
  30. // make the pie
  31. var pieOne = new Pie();
  32. // fill the pie
  33. pieOne.setFilling('apple');
  34. // what's in the pie?
  35. console.log(pieOne.getFilling()); // apple
  36.  
  37. // make another pie
  38. var pieTwo = new Pie();
  39. // fill the pie
  40. pieTwo.setFilling('steak');
  41. // console.log('your account has been deleted');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement