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

analyn jane calado
analyn jane calado
3,523 Points

what code is missing???

i got stock here!

script.js
var count= 1;
while (26 ) {
    document.write("<p>26" + count + "</p>");
    count += 1;
}

1 Answer

rydavim
rydavim
18,814 Points

Right now you've got an infinite loop, because while (26) will always evaluate to true. Additionally, you normally don't want to make alterations to challenge code unless they specifically ask you to.

var count = 0; // Leave this as 0, just in case!

while (count < 26) {  // While the count is less than 26...
  document.write("The count is: " + count); // Write something meaningful to the document so you can keep track of what's happening.
  count++; // Increment the count by one. This is just a shorthand for this.
}