Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Create a program that uses a multidimensional array to hold songs and artists, and then displays a playlist of each song, with the artist who recorded it and the duration of the song.
Multidimensional array snippet
const playlist = [
['So What', 'Miles Davis', '9:04'],
['Respect', 'Aretha Franklin', '2:45'],
['What a Wonderful World', 'Louis Armstrong', '2:21'],
['At Last', 'Ella Fitzgerald', '4:18'],
['Three Little Birds', 'Bob Marley and the Wailers', '3:01'],
['The Way You Look Tonight', 'Frank Sinatra', '3:21']
];
Resources
Spread syntax and multidimensional arrays
Note: Spread syntax effectively goes one level deep while copying an array. Therefore, it may be unsuitable for copying multidimensional arrays, as the following example shows.
const brass = [ ['trumpet'], ['tuba'], ['trombone'] ];
const instruments = [...brass];
instruments.shift().shift();
// "trumpet"
// Notice how the brass array is also affected by this:
brass
// [ [], ["tuba"], ["trombone"] ]
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up