Prototype: chooseSpot(spots,vehicleKind) takes [spotId,kind] pairs, all free, and returns an ID or null. Kinds are exactly motorcycle/car/van in increasing size; IDs are nonempty and unique. Validate the entire input, including unselectable spots, then choose smallest compatible kind/ID. Preserve input.

Final: new ParkingLot(spots) copies the same validated inventory, including empty. park(vehicleId,kind) returns {ticketId,vehicleId,vehicleKind,spotId} or null if no capacity. Duplicate active vehicle raises RangeError. Ticket IDs start 1 and advance only on success. release(ticketId) requires a safe integer and returns released snapshot or null once absent. activeTickets() is ticket-ID ordered; availableSpots() returns kind/ID ordered pairs. Releasing permits that vehicle to park again.

Every class is exported by name from exercise.mjs. Keep instances independent. Unless explicitly documented otherwise, input values have the stated collection/string types and do not contain null elements. Invalid calls preserve state; validate before mutation. Return fresh mutable snapshots unless stated otherwise.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.