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,611 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);