Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Using For Loops with Arrays

Saqib Ishfaq
Saqib Ishfaq
13,912 Points

ok i did not get whats happening with 1. " listHTML" here? 2.and whats "print" purpose here?

3.and whats the point of "function print (message)" ?

  1. and wot does that do and why do we need this += here
listHTML += '</ol>';

any simpler and non-confusing explaination to the whole lesson plz! as i was enjoying this arrays session upto this point and it feels like i hit the brick wall all of a sudden(facepalm)

2 Answers

Steven Parker
Steven Parker
231,275 Points
  1. the "listHTML" variable is holding a string that is being constructed in several operations
  2. the "print" function just puts the string argument onto the page
  3. the "+=" is a concatenating assignment, basically it means "add this onto the end"
Saqib Ishfaq
Saqib Ishfaq
13,912 Points

only thing m still confused about is passing "list" as an argument to the function "printList" and then in for loop we using length property to check the no of items in that. but where is "list" to check the length property for it? is this an imaginary list for as many as no of items in the list?

Saqib Ishfaq
Saqib Ishfaq
13,912 Points

i understand i was actually reading ur answer posts from 29th june to a student micheal ,of almost similiar questions. helped alot! thanks