This assignment is to create a small library app using a Book Class in JS. I have everything done except for a markRead method it wants me to make in the Class. I'm having trouble conceptualizing one of the steps.
This is my JS for the project.
class Book {
constructor(title, author, read) {
this.title = title;
this.author = author;
this.read = read;
}
}
//Create a new library class for constructing.
class Library {
constructor(count, books) {
this.count = count;
this.books = books;
}
markRead = function (checkbox, id) {
for (let i = 0; i <= books.length; i++) {
if (xxx id == b) {
this.markRead = true;
document.checkbox = true;
check = true;
}
}
And this is the section of the HTML that goes along with it.
<tbody>
<tr>
<td>Name of the Wind</td>
<td>Patrick Rothfuss</td>
<td>
<input
type="checkbox"
name="read"
id="readLibraryCheckbox"
checked
disabled
/>
</td>
</tr>
</tbody>
I'm on the markRead section of these instructions.
1. Create a class `Book` that has the following properties:
- Title (string)
- Author (string)
- Read (boolean)
2. Create a class `Library` that has the following properties and methods:
- Book count (number)
- Books (array of books)
- `markRead` method that will:
- Take in a parameter `checkbox` and `id`
- Loop through the library books
- If the book id is the same as the param id, change the book read property to true, the `checkbox` checked attribute to true, and the `checked` disabled attribute to true