JavaScript: Classes [Build a Library] project (Completed)

Hey guys! :smiley:
Just finished ‘Build a Library’ project.
I wanted to do the last task (no. 25) as well so I did! (It wasn’t easy)
But I hope you enjoy, if you have feedbacks I’m more than happy to hear them!


  1. In ‘CD’ class, I changed songs to tracks, and created songTitles (for more detailed content).
  1. I added a addSongTitles function, and if the number of songs you inserted in a CD instance is higher than the actual number of song title inserted, the songTitle getter will show the difference as ‘unknown title songs’.

    JavaScript ‘Classes’ Project << Check it out! :hatched_chick:

Happy coding! :green_heart:

1 Like

Job well done! :clap:

I like your simple approach to the .shuffle() method, returning 1 random song. In my version I built an array of the entire track list in random order, but since there’s no easy way to remove an item from an array, it turned into a bit of a mess…

Although the use of mediaList.push() in the constructors is convenient - it automatically adds each item to the catalog - it probably isn’t best practice because it relies on mediaList being declared. What if someone imported this functionality, but didn’t instantiate a mediaList or called it something else? Probably better to have an add method in the Catalog class, then add everything manually.

It looks like the third conditional in songTitles (line 111-113) returns a number instead of the titles, is that what it’s meant to do?

console.log(myLover.songTitles); // returns 3