Solution Review: Let's Make a Burger
This lesson will explain the solution to the problem in the previous lesson.
Solution #
Press + to interact
class Vegetables {veggies() {return "Choose Veggies"}}class Meat {meat() {return "Choose Meat"}}class Sauces{choosingSauces(){return "Choose Sauces"}}function combineClasses(dest,...src){for (let _dest of src) {for (var key of Object.getOwnPropertyNames(_dest.prototype)) {dest.prototype[key] = _dest.prototype[key]}}}class Burger{}//adding a new classclass Cheese{addingCheese(){return "Add Cheese"}}combineClasses(Burger,Vegetables,Meat,Sauces,Cheese)var burger = new Burger()console.log(burger.veggies())console.log(burger.meat())console.log(burger.choosingSauces())console.log(burger.addingCheese())
Explanation #
The challenge had the following requirements:
-
The methods of all classes should be available to the
Burger
class. -
If any ...
Access this course and 1400+ top-rated courses and projects.