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

we learned to add HTML from JS with querySelector method but here we see a different method, he doesn't explain this.

As we learned earlier in java script course we have learned to add javascript querySelector mehtod but here we see instructor has been using different method and he did not explaining this. Can anybody from treehouse tell me why this happening?

Steven Parker
Steven Parker
230,274 Points

Which other method are you referring to, and at what time in the video is it used?

Anton Paluykh
Anton Paluykh
8,994 Points

You are right. JS Basics was updated with es2015. And this course is a little bit out of date. They have promised to update this course in May2020 , but now I see it will be only in June 2020. I think you mean this as it it was with Guil at JS basics

 const printList = list => {
 let listArtist = '';
  for ( let i = 0; i < list.length; i += 1) {
     listArtist += `<li>${list[i]}</li>`;
  }    
   document.querySelector('ol').innerHTML = listArtist;
}

5 Answers

Steven Parker
Steven Parker
230,274 Points

The course that most thoroughly covers how JavaScript and HTML interact is JavaScript and the DOM. You may want to take it next, or even set this one aside and take it first and return to this one aftewards.

ok. I mean here in the video teacher is printing something in the HTML file form the Java Script file. i do not understand how this is happening here. And he did not expalin how HTML and JS is interacting with each other.

That was in JavaScrip Basic course, "working with the string" Section and the lecure title was "Display the Value of a String on a Page". The main thing is what the teacher is doing here something with java script and HTML is totaly unclear and confusing.

Steven Parker
Steven Parker
230,274 Points

I meant what method is being used in this course, and what time index in this video (the one linked to the "Watch Video" buton above).

Nasra Iid
seal-mask
.a{fill-rule:evenodd;}techdegree
Nasra Iid
Front End Web Development Techdegree Student 9,876 Points

Guil did it using string interpolation ${} .. where as this course is using string concatenation.

At the beginning of this course they did say " feel free to use string interpolation" and const and let instead of var

Thanks.