Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Cake {
- constructor(type, flavour) {
- this.type = type;
- this.flavour = flavour;
- }
- addCherry() {
- this.isCherryAdded = true;
- }
- }
- const vanillaCake = new Cake('butter', 'vanilla');
- const chocolateCake = new Cake('sponge', 'chocolate');
- vanillaCake.addCherry();
- console.log(vanillaCake.isCherryAdded); //returns true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement