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 Simplify Repetitive Tasks with Loops For Loops

yoav green
yoav green
8,611 Points

white screen when running the code

var html = '';

for (var i = 1; i <= 10; i+=1) { html += '<div>' + i + '</div>'; }

document.write(html);

why am i getting only a white screen?

Okay, I was having the same thing happen and when I looked in the console it said that the .js file did not exist. How I fixed it was deleting my js folder and it's contents and created a new one. After that it worked perfectly, nothing is wrong with the code.

1 Answer

Balazs Peak
Balazs Peak
46,160 Points

Your code works just fine. Maybe you've forgot to reference the js file from index.html? You have to include, it's not enough to have it in the project folder.