Café Drinks Class
JavaScript
10 pts
Café Drinks Class
Finish the class Drink for the Asmara café:
- The constructor saves
nameandpriceonthis. - A method
label()returns text likeTea - 15 Nakfa(use a template literal).
The objects tea and coffee are already created. Print tea.label(), coffee.label() and then tea itself. Expected output:
Tea - 15 Nakfa
Coffee - 20 Nakfa
{ name: "Tea", price: 15 }
Checklist
- The constructor of
Drinksavesnameandprice. - Add a
label()method that returns the name and price in Nakfa. - Keep the two drink objects made with
new. - Print both labels and then the
teaobject.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
