Pass Multiple Inputs to One Function
Scenario
Trace calling canBookRoom(freeSeats, hasPermission) with arguments (2, false).
- 1Call: canBookRoom(2, false)
- 2Evaluate: freeSeats > 0 AND hasPermission
- 3Return false (Declined)
Try it yourself
Step through how each argument binds to its parameter and produces the final decision.
| Case | State after the step |
|---|---|
| Call: canBookRoom(2, false) | — |
| Evaluate: freeSeats > 0 AND hasPermission | — |
| Return false (Declined) | — |
Reveal the explanation
- Call: canBookRoom(2, false)
Argument 1 binds freeSeats = 2; argument 2 binds hasPermission = false.
- Evaluate: freeSeats > 0 AND hasPermission
2 > 0 is true, hasPermission is false -> true AND false = false.
- 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.
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
This browser could not save your progress. Changes last until you leave the page.