So i have this array:
var musicQuiz = [
{
lyrics: "Now the drugs don´t work",
answers: [
"The Verve",
"Oasis",
"Adele",
"Rolling Stones",
"Chris de Burgh",
"Ceasars"
]
},
{
lyrics: "Go your own way",
answers: [
"The Chemical Brothers",
"U2",
"The Doors",
"Fleetwood Mac",
"Moloko",
"The Beatles"
]
}
];
I want to show the "lyrics" randomly.so I have this:
for (var i = 0; i < musicQuiz.length; i++) {
var question = document.getElementById("question");
var random = Math.floor(Math.random() * musicQuiz[i].lyrics.length);
question.textContent = musicQuiz[i].lyrics[random];
}
But it's not working, it only shows a letter. I saw how to do this with an array, but can't figure it out to do it like this. Any help and explanation would be good.