I have an array of objects:
const song = songs.map(song => song.title);
const playlist = [
{
url: `/music/${song[0]}.mp3`,
title: `${song[0]}`
},
{
url: `/music/${song[1]}.mp3`,
title: `${song[1]}`
},
{
url: `/music/${song[2]}.mp3`,
title: `${song[2]}`
}
];
I need to create dinamically playlist array of objects with as many items are in songs array without specifying them directly,
something like this:
const playlist = [
{
url: `/music/${song}.mp3`,
title: `${song}`
}
];
How to approach this? Can i use push or slice methods?
playlistwith as many items are insongarray without specifying them directly?