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

Patrick Vanegas
Patrick Vanegas
6,971 Points

copied dave's exact code and made sure the source to the script was good, but I'm still not seeing anything

var html ='';

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

document.write(html);

and in the index.html file : <style src="js/script.js"></style>

I made sure the file was in the js folder as well, and still nothing. The console isn't popping anything up either.

Is this possibly a bug in workspace, or am I going crazy?

4 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Well, the good news is that when I run your code directly in the console, it works! So at least we know it's not the code. The odds of this being a bug in workspaces is pretty slim given that even though this is coded in workspaces, the code is executed in your browser.

So, let's check some basics first. Make sure you saved the JS file you just edited. If there's an orange dot on the tab, it's not saved. Also, there's the chance that your browser is loading in a cached version of your code. Try clearing the browser cache, reloading the preview and then refreshing the page. If this still doesn't work, we're going to need to see a snapshot of your workspace.

You can make a snapshot by clicking the camera icon in the upper right-hand side of your workspace. Follow the link and then post the link so we can take a look around.

I look forward to your reply! :sparkles:

Patrick Vanegas
Patrick Vanegas
6,971 Points

Here, you go! Tried clearing my browsers cache and nothing worked.

https://w.trhou.se/zo2p5mjbgf,

https://w.trhou.se/284l96pjyx

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

I apologise. The first time I looked at the code, I didn't see the error. But I see it now. Your link is inside a style tag, but it should be inside a script tag.

Take a look:

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

Hope this helps! :sparkles:

Patrick Vanegas
Patrick Vanegas
6,971 Points

Ahhhhh, it worked now!! Thanks a lot! wow, it's so easy to miss something like that... :D

Hello, Thanks for asking on treehouse forum. Could you please correct the <div></div> thanks, :)

nvm its right sorry I didn't see very well