Build a Library - Step 5

I have done the step 5 which is:
Create a setter for the isCheckedOut property.

However when I tried to console.log(test1.isCheckedOut(true)); I am getting an error test1.isCheckedOut is not a function

Any help would be very great.

Here’s my code so far. . .

/* Parent Class */

class Library {

constructor(title) {

this._title = title;

this._isCheckedOut = false;

this._ratings = [];

}

get title() {

return this._title;

}

get isCheckedOut() {

return this._isCheckedOut;

}

set isCheckedOut(value) {

this._isCheckedOut = value;

}

get ratings() {

return this._ratings;

}

getAverageRating() {

}

toggleCheckOutStatus() {

}

addRating() {

}

}

    /* Class Instance 1 - Book */

class Book extends Library {

constructor(author, title, pages) {

super(title);

this._author = author;

this._pages = pages;

}

get author() {

return this._author;

}

get pages() {

return this._pages;

}

}

const test1 = new Book(‘Cedd’, ‘Test1’, 150);

console.log(test1.isCheckedOut(true));

To set the value of the setter, you’ll set it like you’re initializing a variable.

Test1.isCheckedOut = true;

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set

1 Like

Got it! Thanks for your help