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

Nick Manring
Nick Manring
11,369 Points

Are there issues with using workspace on Chrome? I'm not getting the same results

My index.html and script.js files are exact to the video and I've tried the same text in Sublime text as well but the divs are not displaying in Chrome or Safari. Is this an issue on my end or is the code missing something?

  • I can't include the HTML because this window compiles html code no matter what commenting i do. but i assure it you it exact to the lesson *

script.js ------

var html = ' ';

for (var i = 1; i <= 10; i += 1) {
html += '<div>' + i + '</div>';
}
document.write(html);
Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

MOD edit: added mark down to display your code in a code block.

You can display HTML in a code block as well. After last line in text box, hit enter twice.

Put 3 back ticks followed by programing language name (no spaces) and hit enter.

Paste code

Close block with 3 back ticks (on a new line)

2 Answers

Trevor Storey
Trevor Storey
4,238 Points

You can try going to your html sheet and taking out the folder name from your script reference source... I'm not sure why this worked for me exactly...but it did.

<script src="/script.js"></script>
Richard Rogers
Richard Rogers
18,880 Points

This solved my issue. Hmmmm

Andrew Robinson
Andrew Robinson
16,372 Points

Your code seems to work just fine for me in Chrome Version 44, you might want to double check your script element in the html, it should be something like:

<script src="js/script.js"></script>

to display any code in a post do:

```langauge

code here

```

replacing language with html, css, javascript etc.