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

help with, While loop

I've done everything right but I've notice the Document.write is a little off, what can I do to fix the solution?

script.js
var count = 0;
while (count < 26) {
 document.write('# of loops');
  count += 0;



}

2 Answers

Agnes Demes
Agnes Demes
6,613 Points

Hi, There are a couple of things in your code that will not let you pass this quiz. console.log('# of time'); would print the string 26 times such as:

1) # of times # of times # of times # of times # of times # of times etc so instead of adding a string you need to insert the count value ( count);

2) count += 0 means take the current value of count and increase it by 0, therefore it would stay the same. you need to have count+= 1;

Andrew LeQuang
Andrew LeQuang
4,970 Points

You want to document.write the variable count. ‘# of loops’ is not a defined variable.

document.write(count);