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

Jeremy Grondahl
Jeremy Grondahl
4,210 Points

Nothing shows up in preview after following the steps in the video.

I noticed the preview title at the end of the video opens up as "Circles." However, my preview window automatically opens up as "Squares" as it's title. Could their be any changes in the css or html files in Workspace that would prevent me from previewing the website? Thank you!

Hey there, I can probably give you a hand if you can provide your source code and js

Jeremy Grondahl
Jeremy Grondahl
4,210 Points

Thanks!

<script src="js/script.js"></script> 
var html = '';

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

3 Answers

If you're still stuck on this. I might be able to help. Have you finished this or moved on?

Okay. In your question, you only posted a single block of JS code and your source in the HTML.. If you could post your html and js source code, I'll be better equipped to find the problem

Jeremy Grondahl
Jeremy Grondahl
4,210 Points
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Squares</title>
  <link rel="stylesheet" href="css/styles.css">
</head>
<body id="color">
<script src="js/script.js"></script>
</body>
</html>

Go into workspaces and copy/paste into here all of your code. the entire html file, the entire js file and the entire css file.. wrap each with '''html ---insert code---''' for html '''javascript ---insert code---''' for js and '''css ---insert code--- '''

The ---insert code--- part is where you should paste your code in each case. In other words, wrap each bit of code with three single quotes and the code type, then the code, then three single quotes.

Doing this will post what you're working with and we can go from there. :)

Olyn LeRoy
Olyn LeRoy
1,068 Points

I was having the same issue, try fixing the link to your script.js in your HTML file to only be: src= "script.js" When I added the script.js file to the workspace it wasn't added to the js folder, so index.html wasn't finding it.

Mark Lopresto
Mark Lopresto
8,180 Points

Because of the way the file script.js sits under the js folder, it looks like it is nested in the folder when it may not be. You can remove the js/ in front of script.js in your html like Olyn said above, or you can drag your script.js file up into the js folder to verify that script.js is really inside of the js folder. You will see the script.js file nest further over and your page will work once file is saved and page refreshed.