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 trialLearning coding
Front End Web Development Techdegree Student 9,937 PointsWhy isn't my code running that Dave is explaining?
Double checked it a few time's, but the code doesn't run. https://w.trhou.se/r5nggdhy02
3 Answers
andren
28,558 PointsWhen you declare the for
loop you are missing the i
variable in your comparison. It's meant to be i <= 100
you just have <= 100
.
If you add the i
like this:
var html = '';
for (var i =1; i <= 100; i +=1 ) { // Added "i" to the comparison (middle) step
html += '<div>' + i + '</div>';
}
document.write(html);
Then your code will work.
Learning coding
Front End Web Development Techdegree Student 9,937 PointsThanks, i see and understand.
Amy Clark
7,892 PointsI've tried several versions of code and I'm not getting it to work. Including the answer above!
Justin Houghton
4,560 PointsI had the same issue - my issue was that when I created the script.js file, I didn't put it within the js folder. I just right clicked and created a new folder.
Once I dragged the file into the js folder, the link on the index page worked and I was able to preview the divs.