Jump to content

RJL1

Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About RJL1

  • Rank
    Newbie
  • Birthday October 25

Previous Fields

  • Languages
    HTML, CSS

Profile Information

  • Gender
    Not Telling
  1. var fruits, text, fLen, i; fruits = ["Banana", "Orange", "Apple", "Mango"]; fLen = fruits.length; text = "<ul>"; for (i = 0; i < fLen; i++) { text += "<li>" + fruits[i] + "</li>"; } text += "</ul>"; Hi, Im a beginner trying to learn some javascript code and I cant seem to wrap my head around this. In the loop the text variable "<ul>" has "<li>" + fruits + "</li>" added to it becoming: text = "<ul>" + "<li>" + fruits + "</li"> inside the brackets. Why isnt the "<ul>" looped 4 times like the rest of the code? In my mind the output should be: < "<ul>" + "<li>" + fruits[0] + "</li>"; "<ul>" + "<li>" + fruits[1] + "</li>"; "<ul>" + "<li>" + fruits[2] + "</li>"; "<ul>" + "<li>" + fruits[3] + "</li>"; "</ul>" But it's not... Can someone explain? I hope it makes sense. Thanks in advance
×
×
  • Create New...