Build a library model using the equipment desk's pattern. LibraryItem owns the title and private loan status. Book adds an author and a description while inheriting the loan rules.
The class structure and probes are supplied; complete one behavior at a time in script.js. Book cannot directly read #checkedOut, even though it inherits from LibraryItem. Read the inherited available getter instead. A new book is available, a successful checkout makes it unavailable, and a successful return restores availability.
The description should work in either state and use the instance's title and author, not a fixed sentence. The probes follow both state transitions before asking for the final description.
A different private-state class exposes behavior without exposing its field:
class Lamp {
#on = false;
switchOn() { this.#on = true; }
get isOn() { return this.#on; }
}
const lamp = new Lamp();
lamp.switchOn();
console.log(lamp.isOn);
Edit script.js, then use Run to inspect the supplied checkpoints. Use Submit to check your tasks in order. Keep the supplied probes; change only the requested definitions and final logs.
title in the LibraryItem constructor.#checkedOut from the available getter.author in Book after the supplied super(title) call.checkout() to return false if already on loan; otherwise mark the item on loan and return true.returnItem() to return false if already available; otherwise restore availability and return true.Book.describe() as Title by Author — available or Title by Author — on loan, using its public availability getter.You can model shared behavior and protect state while still exposing useful operations. Take the quiz to check where each responsibility belongs.
Call super(title) before assigning the book author.
Keep the loan state in #checkedOut; change it only inside methods.
Return false for an invalid checkout or return without changing state.