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

My code always displays an extra div (grey circle) after the last number with no number in it though. Not sure why.

If I generate 10 divs from the code, I get 11 with the last div (grey circle) empty and misaligned vertically. Here's my code

var html = "";

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

document.write(html);

3 Answers

Steven Parker
Steven Parker
231,275 Points

This code simply makes 10 div elements containing sequential numbers (1 - 10), all left-aligned. No circles or other graphic elements.

Is there some HTML and/or CSS and/or additional script that goes with this?

Joerg Strohbach
Joerg Strohbach
3,049 Points

Same problem here. Looking at the generated HTML code I figured out, that one of my installed browser extensions (Clip to Devonthink) created the last, empty circle.

Here is the line I found in the HTML source:

<div id="cliptodevonthink-is-installed"></div>

Steven Parker
Steven Parker
231,275 Points

That's a rather naughty browser extension!

I had not heard of "Devonthink" before, but perhaps this article I found on their website might help: When Chrome doesn’t like Clip to DEVONthink.

Jessica Foster
Jessica Foster
6,950 Points

I have the same problem. For me it's the Snagit extension I use for taking screenshots:

<div id="techsmith-snagitchrome-extension"></div>