Since I am a beginner, I have also been going over the JS tutorials on openclassrooms and have come to the last challenge app for tracking book reading. So the thing is if the input pagenumber is the last pagenumber the book should be considered “read” . I checked it in console and the value turns to “true” so when I click the update the page numbers it works but the frame doesn’t turn green.
class Book {
constructor (title, author, pages, description, currentPage, read) {
this.title = title;
this.author = author;
this.pages = pages;
this.description = description;
this.currentPage = currentPage;
this.read = read;
}
readBook(pageNumber) {
if (pageNumber > this.pages) {
alert("Page number doesn't exist")
}else if (pageNumber === this.pages) {
this.currentPage = this.page;
this.read = true;
}else {
this.currentPage = pageNumber;
}
}
}
const firstBook = new Book ("Eternal love", "John Smith", 300, "Love Book", 1, false);
const secondBook = new Book ("Eternal hate", "John Doe", 200, "Hate book", 1, false);
const thirdBook = new Book ("Crime drama", "John Johnson", 350, "Crime book", 1, false);
const bookList = [firstBook, secondBook, thirdBook];