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

Ismael Sanchez
Ismael Sanchez
2,884 Points

I think there is an error in this challenge.

Is there not supposed to be a document to write to? Since there is none I believe document.write() is not working.

script.js
var count = 0;
while(count < 26){
  document.write("Hello");
}

2 Answers

andren
andren
28,558 Points

There is a document to write to, it's just not shown because it's not something you need to see or interact with to complete the challenge. The issue with your code is that the loop you have written runs infinitely due to the fact that you never increase the count variable within the loop, which means that it will always be less than 26.

If you add some code to increase count within the loop then your code will work fine.

Jonathan Dewitt
Jonathan Dewitt
8,101 Points

You are missing some important parts of your while condition. Try putting the var count = 0 into it, before checking the value, and then increment it by 1 after each check.