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 trialGal Parselany
Full Stack JavaScript Techdegree Graduate 26,281 PointsI did it another way, is that ok? or I have some bug that I dont see yet :
for (i = 1; i < 11; i++) {
main.innerHTML += <div>${html}${i}</div>
;
}
1 Answer
Steven Parker
231,268 PointsYour code produces items numbered 1 to 10, where the video code creates 0 to 9. Otherwise, the result is identical.
The video code builds up the "html" string in the loop first and then outputs it one time, where this code is outputting each element one at a time.
Also, since you're not assigning anything to the "html" variable you can eliminate it entirely:
for (i = 1; i < 11; i++) { main.innerHTML += `<div>${i}</div>`; }
Gal Parselany
Full Stack JavaScript Techdegree Graduate 26,281 PointsGal Parselany
Full Stack JavaScript Techdegree Graduate 26,281 Pointsthanks again!