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

Sufiyaan Haroon
seal-mask
.a{fill-rule:evenodd;}techdegree
Sufiyaan Haroon
Full Stack JavaScript Techdegree Student 9,558 Points

UHHH... It doesn't work.

I wrote all this code as said in the video but nothing except for a empty page shows. Here is the code:

var html = '';

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

Please someone tell me fast.

4 Answers

Sufiyaan Haroon
seal-mask
.a{fill-rule:evenodd;}techdegree
Sufiyaan Haroon
Full Stack JavaScript Techdegree Student 9,558 Points
<!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>
Alexandra Barnett
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexandra Barnett
Front End Web Development Techdegree Graduate 46,473 Points

Which browser are you using? Perhaps it's been cached and you aren't seeing the updated version...otherwise I'm not entirely sure because it should work...I'm sorry I can't be of more help :(. I find that, on Google Chrome, I have to sometimes open the developer console and do a "hard reload" by pressing command+R or clear the browsing data from the settings...

Garrett Freshwater
Garrett Freshwater
2,378 Points

Haha, I was having the same issue as you Sufiyaan. Also, same solution. Thanks!