Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. class Cake {
  2. constructor(type, flavour) {
  3. this.type = type;
  4. this.flavour = flavour;
  5. }
  6.  
  7. addCherry() {
  8. this.isCherryAdded = true;
  9. }
  10. }
  11.  
  12. const vanillaCake = new Cake('butter', 'vanilla');
  13.  
  14. const chocolateCake = new Cake('sponge', 'chocolate');
  15.  
  16. vanillaCake.addCherry();
  17. console.log(vanillaCake.isCherryAdded); //returns true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement