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

why document.write may not be called in js file ? help

help me to make the code run and prints something 26 times on the document.write

script.js
var count = 0;
while (counter < 26){
  var counter= counter (26);
   document.write(counter + ' ');
  counter += 1;
}

1 Answer

Your answer is technically correct with the exception of the counter variable. For one it is not defined outside of the while loop and secondly it is not required and should be changed to count.

var count = 0;
while (count < 26){
   document.write(count + ' ');
  count += 1;
}

I hope this helps