Jump to content

bmjaczynski

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by bmjaczynski

  1. Yes it's correct code, but I'm new to coding so it seems my logic is flawed when I try to break it down and I'm not sure why. Why isn't the variable 'text' being looped since it's looping what looks to me like: for (i = 0; i < fLen; i++) { text += "<li>" + fruits[i] + "</li>"; // "<ul>" = "<ul>" + "<li>" + fruits[i] + "</li>" } Same for the last line: text += "</ul>"; // "<ul>" = "<ul>" + "</ul>"
  2. For this example: 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>"; why does the last line output as </ul> instead of <ul></ul>? Since it is using the += operator.
×
×
  • Create New...