I am trying to convert an array of sentences into unordered HTML lists, with each list item containing a word from the sentence. For example: [I play piano the can'] t
<ul>
<li id = number</li>
<li>I</li>
<li>play</li>
<li>piano</li>
<li>the</li>
<li>can</li>
</ul>
However, when I use this code to iterate through the array:
function makeQuest() {
var quest=['I play piano the can', 'tired I am', 'are seven There week in a days'];
for (var i=0; i< quest.length; i++){
document.write('<ul class ="div3">')
document.write('<li id = "number">' + (i + 1) + '.' + ' '+ '</li>')
for (var j=0; j < quest[i].length; j++){
document.write('<li>')
document.write(quest[i][j])
document.write('</li>' + '</ul>')
}
}
};
makeQuest()
The output is not as expected:
1.I
play piano the can
2. t
ired I am
3. a
re seven There week in a days.
I need help identifying what I am doing wrong in my script.