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
John Park
4,368 PointsFor Loops issue
I am producing a weird result when I try to run this code similar to Dave's excercise. What I am seeing is the div closing tag at the end. Here is my code and results.
''' var html = '';
for (var i = 1; i <= 10; i += 1) { html += '<div>' + i + '/div>'; }
document.write(html);
html
1/div> 2/div> 3/div> 4/div> 5/div> 6/div> 7/div> 8/div> 9/div> 10/div>
1 Answer
paulscanlon
Courses Plus Student 26,735 PointsHey
You missed off a < on the closing tag, so it is just rendering as a string, also try
var html = "";
Hope this helped
Happy coding
Paul
paulscanlon
Courses Plus Student 26,735 Pointspaulscanlon
Courses Plus Student 26,735 PointsAlso try encapsulating your code between two sets of 3 backticks when you ask a question in the forums, makes it easier for us to read. Check out the markdown cheatsheet below for more info :)