Recap Challenge
Part of the Object Oriented Programming section of Coddy's JavaScript journey — lesson 14 of 56.
Challenge
Create a VendingMachine class that represents a drink vending machine with the following:
Properties:
location(string): where the machine is locateddrinks(number): how many drinks are left
Methods:
getStatus(): returns a string like "Cafe machine: 15 drinks left"
Try it yourself
import { VendingMachine } from './VendingMachine.js';
// Test - don't modify this part
const cafeMachine = new VendingMachine("Cafe", 20);
console.log(cafeMachine.getStatus()); // "Cafe machine: 20 drinks left"
All lessons in Object Oriented Programming
1Objects & The this Keyword
Quick Review: ObjectsAdding Methods to ObjectsUnderstanding the this KeywordConstructor FunctionsThe new KeywordRecap Challenge7 Inheritance & The extends Key
InheritanceThe "is-a" RelationshipThe extends KeywordThe super() MethodInheriting Properties&MethodsRecap Challenge2Organizing Code
What are Modules?Exporting with exportImporting with importDefault vs. Named Exports8Organizing OOP Code
Organize Classes into Modules11Project: A Shape Renderer
Setup: Shape Class & ExportCircle Class Inheritance9Static Methods & Properties
Class-Level vs. Instance-LevelStatic PropertiesStatic Utility MethodsRecap challenge