Curriculum

Curriculum

Test the Last Available Seat

Scenario

The room accepts bookings only when freeSeats is greater than zero.

Selected choicePick a choice below
Result—

Try it yourself

Choose a seat count and predict the decision before opening the result.

Reveal the explanation
  1. 0 free seats

    Declined. The room is full.

  2. 1 free seat

    Accepted. The last seat may be booked.

  3. 2 free seats

    Accepted. The booking leaves room for another seat.

A check using >= 0 would overbook a full room. Keep both 0 and 1 in the test set.

Download shared test cases

Your turn

Write the expected result for 0, 1, and 2 free seats before you run the checker.

Common mistake Using a comparison that admits a booking when the room is full.

Check your work

The expected results are false, true, and true.