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 trialBlake Piper
1,223 PointsWhy suddenly all this HTML?
i was on board with all the arrays and loops and was starting to understand things. seems like out of nowhere he just starts throwing around HTML code like im suppose to know what it means? '<ol>' '<li>'. never seen that before and its really throwing me for a loop (pun intended).
function printList( list ) { var listHTML = '<ol>'; for ( var i = 0; i < list.length; i += 1){ listHTML += '<li>' + list[i] + '</li>'; } listHTML +='</ol>'; print(listHTML);
makes it harder for me to understand whats going on when hes throwing around terms and html stuff that i have no clue about. did i miss something?
5 Answers
varlevi
8,113 PointsIf you are confused by the HTML, I would recommend taking the HTML basics course after you finish the JavaScript course you are currently taking, but until then don't worry too much about it and just copy what the teacher writes. If you feel that HTML is being used a lot in this course, however, you may want to ask Support to add the HTML Basics course to the prerequisites for this course.
varlevi
8,113 PointsBasically what you're encountering here is the DOM, or Document Object Model. You interact with DOM whenever you change HTML (or CSS) using JavaScript. It is probably one of the things JavaScript is most commonly used for, so it is definitely something to explore more. Treehouse has a great course on it I took this summer that explains all the basics, so I would highly recommend starting your studying there. It can be found at https://teamtreehouse.com/library/javascript-and-the-dom-2. Hope this helps!
Elena Prokudina
2,119 PointsThank you very much
varlevi
8,113 PointsAny time. Glad I could help!
Elena Prokudina
2,119 PointsI think that this is not a question of html, but a question of interaction between JavaScript and Html. Could someone tell me what the name of this interaction is, so that I can find information about it to study.
Connor Sayers
1,515 Points<ol> - This stands for 'Ordered List', any list item within this tag will be assigned a number in order e.g. 1. 2. 3. 4.
<li> - You place this tag inside the Ordered List to show each individual list item.
EXAMPLE CODE: <ol> <li>List Item One</li> <li>List Item Two</li> <li>List Item Three</li> </ol>
OUTPUT:
- List Item One
- List Item Two
- List Item Three
While you don't need to know HTML to learn JavaScript, it's a good idea to understand it as they work hand in hand. I agree with varlevi's comment when they say take the HTML basics course as it will teach you the basic syntax.
tomaszfurmanczyk
Full Stack JavaScript Techdegree Student 18,242 PointsElena I think what you're asking when you mention "interaction" between HTML and JAVASCRIPT is that this is a form of concatenation
//When you see this concept of concatenation
var a = "The stranger ";
var b = " wants a hug.";
var c = a + b;
console.log(c);
//or
print(c);
//It's very similar to this concept just adding in a loop:
//variable including the start of a HTML ordered list tag var listHTML = '<ol>';
//loop for ( var i = 0; i < list.length; i += 1){
//concatenating to the variable adding each listed item and surrounding it with list open and closed tags listHTML += '<li>' + list[i] + '</li>'; }
// closing with the ordered list tag listHTML +='</ol>';
//Then printing out the result of the variable print(listHTML);
Diego Alvarez
6,680 PointsDiego Alvarez
6,680 PointsThey should definitely add it as a prerequisite :P I know HTML but if I haven't, I would be very annoyed.
Even though, checking the comments in the first lessons, people say we must take the HTML Course from the 'Tracks'. But this Tech Degree should warn you at the beginning as well. Maybe add another step that says 'Go learn HTML before proceeding' . Lol.