Use a setter to add multiple things to an array

I am doing the build a library project - https://www.codecademy.com/courses/introduction-to-javascript/projects/build-a-library

I have this class

class Movie extends Media{
constructor (director, title, runTime){
super (title);
this._director = director;
this._runTime = runTime;
this._movieCast=
}

I want to make a setter that lets me add multiple items to the moviecast array. at once. Is this possible?

addCast (value) {
this._movieCast.push(value)
}

speed.addCast (‘Tom’, ‘Rick’, ‘Harry’)

This just adds one item to the array at a time.

I am wondering if it’s possible to add the cast when I add a new Movie.

Hey,

You could present an array instead of single values separated by comma’s.

addCast (value) {
   this._movieCast = value;
}

speed.addCast(['Tom', 'Rick', 'Harry'])
1 Like