Menu
Coddy logo textTech

Recap Challenge

Part of the Object Oriented Programming section of Coddy's JavaScript journey — lesson 14 of 56.

challenge icon

Challenge

Create a VendingMachine class that represents a drink vending machine with the following:

Properties:

  • location (string): where the machine is located
  • drinks (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