Readers can mark or clear a favourite book card. Show the current state beside the card. This follows the Add, remove, and check classes demo.
classList.add("active") adds a class without removing existing classes. classList.remove("active") removes only that class. classList.contains("active") returns a boolean so your code can report the current state. CSS defines what .active looks like; JavaScript only chooses whether the element has it.
Here is the same technique in a different setting; its selectors and data are not the answer to this exercise:
const shelf = document.querySelector("#shelf");
shelf.classList.add("selected");
console.log(shelf.classList.contains("selected")); // true
shelf.classList.remove("selected");
Which method answers a yes/no question about a class? contains. Which two methods change it? add and remove.
In this starter, index.html contains the targets, style.css holds the visual rules, and script.js is where you finish the behavior. Run the preview, make the change, then Submit to check each step. If nothing changes, first check the selector and whether the script is attached at the bottom of the page.
#favourite click, add active to #book-card without losing its note class.Favourite: yes in #favourite-status, checking membership with classList.contains.#unfavourite click, remove active while keeping note.Favourite: no in #favourite-status using classList.contains.