Build a Library Project, JavaScript Syntax Part III, toggleCheckoutStatus

I might just need fresh eyes on this. I cannot get the .toggleCheckoutStatus method to work. I checked my code against the one in the walkthrough video multiple times and can’t see a difference between what I have and what is in the video.

When I use the method on historyOfEverything then log historyOfEverything.isCheckedOut it should show up at “true” but it continues to say false.

I also tried this for a Movie instance and it didn’t work for that either.

What am I missing? Any help appreciated!

class Media { 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() { let ratingsSum = this.ratings.reduce((a,b) => a+b); return ratingsSum / this.ratings.length; } toggleCheckOutStatus() { this.isCheckedout = !this.isCheckedOut; } addRating(rating) { this.ratings.push(rating); } } class Book extends Media { constructor(title, author, pages) { super(title); this._author = author; this._pages = pages; } get author() { return this._author; } get pages() { return this._pages; } }; class Movie extends Media { constructor(title, director, runTime) { super(title); this._director = director; this._runTime = runTime; } get director() { return this._director; } get runTime() { return this._runTime; } }; class Cd extends Media { constructor(title, isCheckedOut, artist, songs) { super(title); this._artist = artist; this._songs = songs; } get artist() { return this._artist; } get songs() { return this._songs; } }; const historyOfEverything = new Book ('A Short History of Nearly Everything', 'Bill Bryson', 544) historyOfEverything.toggleCheckOutStatus(); console.log(historyOfEverything.isCheckedOut) const speed = new Movie ('Speed', 'Jan de Bont', 116); speed.toggleCheckOutStatus(); console.log(speed.isCheckedOut)

Typo on line 32. Once fixed returns true.

Thank you! This was driving me crazy.

1 Like