Curriculum

Curriculum

Pass Multiple Inputs to One Function

Scenario

Trace calling canBookRoom(freeSeats, hasPermission) with arguments (2, false).

  1. 1Call: canBookRoom(2, false)
  2. 2Evaluate: freeSeats > 0 AND hasPermission
  3. 3Return false (Declined)

Try it yourself

Step through how each argument binds to its parameter and produces the final decision.

Reveal the explanation
  1. Call: canBookRoom(2, false)

    Argument 1 binds freeSeats = 2; argument 2 binds hasPermission = false.

  2. Evaluate: freeSeats > 0 AND hasPermission

    2 > 0 is true, hasPermission is false -> true AND false = false.

  3. Return false (Declined)

    Both inputs were combined cleanly without touching any outside state.

Check parameter order carefully whenever two parameters share the same type (such as requestedSeats, freeSeats). Swapping them silently reverses the comparison.

Review first
Download shared test cases

Your turn

Trace canCheckout(isAvailable, borrowedCount) for (true, 2) and (true, 3).

Common mistake Passing (2, true) in reversed order.

Check your work

(true, 2) -> true; (true, 3) -> false.

Quick check

Given canFit(requestedSeats, freeSeats) returning requestedSeats <= freeSeats, what happens if a caller swaps the arguments for 2 requested and 5 free?
Show the answer and reasoning

Correct answer It checks 5 <= 2 and wrongly returns false

Positional arguments bind by order, so passing (5, 2) tests 5 <= 2 instead of 2 <= 5.