Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops For Loops

My javascript wont run

<!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 );

1 Answer

Steven Parker
Steven Parker
216,165 Points

Is that two separate files pasted above? The HTML is expecting the JavaScript to be in "script.js" inside the "js" folder, is that where it is?

To facilitate a more accurate analysis of the issue, make a snapshot of your workspace and post the link to it here.


I'm working on this section of treehouse: For Loops with Dave McFarland

Thanks for the link to the snapshot video. That is SO easy and helpful. As you can now see for yourself. The Javascript is in fact inside the folder js with the name script.js .

Steven Parker
Steven Parker
216,165 Points

In the snapshot, the "script.js" file is in the root (top-level) folder where "index.html" is. The "js" folder is there, but empty.

Just move the "script.js" file into the "js" folder. Either drag it using the left pane, or type "mv script.js js" in the command pane.

And would the person who downvoted this answer please leave a comment and let me know how I can improve? Thanks!

Thanks so much! I wouldn't have caught that otherwise.