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

Jacob Anderson
Jacob Anderson
7,888 Points

I am pretty sure my code is right and I have gone over it a few times but it's still not displaying.

Pretty sure I have my code copied correctly from this lesson but maybe I am just missing something. My problem is that the preview is blank and when I open up my console to see if I have any errors it shows that everything is working correctly.

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Circles</title> <link rel="stylesheet" href="css/styles.css"> </head> <body id="color"> <script> src="js/script.js"</script> </body> </html>

var html = '';

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

4 Answers

Nick Yoho
Nick Yoho
6,957 Points

Make sure your script.js file is in the js folder, the code looks correct to me

Jacob Anderson
Jacob Anderson
7,888 Points

It works now for some reason. Maybe my web browser was doing something funny. Thanks though !

Gonras Karols
Gonras Karols
17,357 Points

please notice your src attribute is outside the script tag - <script> src="js/script.js"</script>, it should be <script src="js/script.js"></script>

Tyler Corum
Tyler Corum
3,514 Points

You have to save the HTML file as well as the JS file. Otherwise the Workspace loads the default (pre-saved) HTML file. (and thus will lack the code to find/run the script)

ye i know both of them are saved not to sure whats going on .

same idk why mine is doing that i have checke multiplie times spelling and everything in the console it keeps saying it s not found and i have saved both pages html and script.js