JavaScript · Exercise 1 of 5Next
Intermediate
Make a playlist iterable
The playlist object holds its songs in a songs array. Make the object itself iterable, so [...playlist] and for (const song of playlist) give the songs in order.
Then fill the #songs list with one <li> per song, using a for...of loop over playlist (not over playlist.songs).
It must work more than once: spreading playlist twice gives the four songs both times.
What Check tests
playlisthas a[Symbol.iterator]method- Spreading
playlistgives the four songs in order - It works twice in a row
- The page lists the four songs
- The loop is
for...ofoverplaylistitself - No errors
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Your page
Press Run to see the page.
Console
Nothing logged yet.