How to pass an array as a constructor parameter? Javascript intermediate Project: Build a Library

Hello everybody,

https://www.codecademy.com/courses/learn-intermediate-javascript/projects/build-a-library

I’m at the ‘finisher’ step of the ‘Build a Library’ project (JavaScript intermediate course), and I have a hard time passing an array of songs as a parameter in a ‘MusicAlbum’ class constructor… Here’s my class declaration:

class MusicAlbum extends Media {
constructor(title, artist, songTitles) {
super(title);
this._artist;
this._songTitles = ;

Here’s my new MusicAlbum object declaration:

const newAlbum = new MusicAlbum(‘New Rock Album’, ‘Rock Artist’, [‘track 1’, ‘track 2’, ‘track 3’]);
console.log(newAlbum);

The songTitles array stays empty… Here’s the log:

MusicAlbum {
_title: ‘New Rock Album’,
_isCheckedOut: false,
_ratings: ,
_averageRating: 0,
_songTitles: }

How can I pass an array of data as a parameter in the constructor?
Thanks in advance!

You’d have to set the properties to be the parameters of the constructor, or use the parameters in some way.

class MusicAlbum extends Media {
  constructor(title, artist, songTitles) {
    super(title);
    this._artist = artist;
    this._songTitles = songTitles; 
  }

Problem solved, thanks a lot!