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

Thaddeus Lorenz
Thaddeus Lorenz
3,434 Points

Confused about the wording of the question

When the question is stating that they want to have something "printed," 26 times, what do they want printed? In the previous video they had 100 random numbers, do they want random numbers or am I making this way more complicated than the problem is asking? If someone could share me what they got I would appreciate it.

script.js
var count = 0;
while ( count < 26 ) {
  document.write(count + ' ')
}
Richard Scott
Richard Scott
25,647 Points

the printed output is the result of the loop, in this case all the numbers betweed zero and 26

you could do it like this

        var count = 0;
        while (count < 26 ){
           document.write(count + "<br />");
           count++;
        }
Steven Parker
Steven Parker
229,785 Points

You wouldn't pass the challenge with "count <= 26". You'd have the wrong number of outputs.

2 Answers

Steven Parker
Steven Parker
229,785 Points

You're right, it's a bit vague.

But I don't think it matters what you print. Just how many times you do it.

So your output is fine as is. But to keep your program from running forever, you still need to increment your counter in the loop!

Thaddeus Lorenz
Thaddeus Lorenz
3,434 Points

Hey Steven, I'm sorry I didn't update you, I was able to figure out the problem. Thank you!

Richard Scott
Richard Scott
25,647 Points

oops you're correct! thanks for spotting, I've amended it. Always helps to read the wording carefully! ha :)