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 Create a while Loop

document.write() method not called?

I'm working on this, and it keeps saying that 'document.write() method was not called. However, the document.write() method is present within the while loops code block. Is there something I'm missing here? Thanks, Anna

script.js
var count = 0;

while ( count > 26) {
  count += 1;
 document.write(count);

}

2 Answers

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

Hi there! You're doing well, but you've mixed up greater than and less than. In this case, the Bummer! message is correct, the document.write() method is never called. You start count at 0, and then you say to run the loop while count is greater than 26. Count will never be greater than 26 unless you reset it. What you meant to say was while count is less than 26.

If I simply change your greater than > to a less than <, your code passes with flying colors! :sparkles:

Thanks so much. I got it eventually, but this clarifies it so that I don't make the same mistake.