I am trying to make a HTML5 playlist using the tag. I want to store all the songs, their name, description, etc… in an array. I don’t know how to use arrays very well though.
What I am thinking right now is this:
var songBase = '/songs/'
var playlist = {};
playlist = {
'Bleeding Love' : 'Bleeding_love.mp3',
'Don\'t Forget' : 'Dont_forget.mp3',
'Finish' : 'Finish.mp3',
'In the Rain' : 'In_the_rain.mp3',
'Ready to Fall' : 'Ready_to_fall.mp3',
'Realize' : 'Realize.mp3',
'Righted All Your Wrongs' : 'Righted_all_your_wrongs.mp3',
'These Walls' : 'These_walls.mp3'
}
What I really need to be able to do is have more than 2 options. I also don’t even know how to extract any of the data from the array that I already have.
Any ideas?
Technically you are using an object literal ({}) there and not an array ([]).
You can use an array of objects literals for your purposes.
You can then access these like:
Or in a loop: