Exercise 04: Define a useful contract
Use a copy of examples/04.
A. Predict
Compare const a = seatLabel(0) with const b = console.log("Full"). Which variable holds useful label text, and why?
B. Improve
Add the singular case so seatLabel(1) returns “1 place available”. Keep the negative and zero cases. Verify -1, 0, 1 and 2.
C. Transfer
Write canFit(available, requested) that returns true only when requested is a whole number at least 1 and no greater than available. Assume available is a nonnegative integer. Test (4, 2), (2, 3), (4, 0), (4, 1.5). Hint: Number.isInteger checks whole numbers.
Evidence
A four-row input/output table and your function. Explain one local name that cannot be used outside the function.