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

still showing a blank page even after i did the exact same code ???? var html = ' '; for (var i = 1; i <=10; i += 1){

why still shoeing a blank page even after i did the same exact code ???? var html = ''; for (var i = 1; i <=10; i += 1){ html += '<div>' + i + '</div>'; } document.write(html);

7 Answers

Okay, as above in the thread, it seems that fadi walter was able to figure it out as they made a post putting the code in the original post into the code format. Which, there was also one or two changes made. The one thing that I noticed in the original code was that there was a double quote at the end of the first variable declaration: var html = "; But later on in the thread when the OP finally put it all in the code format, this was changed to the correct var html = ' ';

I tested both codes. The first way, with the single double quote reacted in the preview the same way the OP described, however, dropping the single double quote, and using the single quotes, the code ran fine.

Alexandros Vasileiou
Alexandros Vasileiou
1,009 Points

Make sure that you created the script.js file inside the js folder. If you didn't then either move it inside the folder and keep the <script src="js/script.js"></script> in your index.html file or change it to <script src="script.js"></script>

i did check the code more than one time. nothing seems to be wrong in the code i believe.

can you post your code?

var html = ' ';
for (var i = 1; i <=10; i += 1){
html += '<div>' + i + '</div>'; }
document.write(html);
Bryant Feld
seal-mask
.a{fill-rule:evenodd;}techdegree
Bryant Feld
Full Stack JavaScript Techdegree Student 26,144 Points

<!DOCTYPE html> <html> <body>

<h1>checked your code on JSfiddle</h1> <p>it seems to be working.</p>

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

</body>

did you check your path for the .js file?