JavaScript JavaScript Loops, Arrays and Objects Simplify Repetitive Tasks with Loops Create a while Loop

Tevi Lawson
Tevi Lawson
5,645 Points

How do I fix this code - please help

I'm not sure what to change here

script.js
var count =1;
while (count <= 25){
document.write("count")
}

2 Answers

furkan
PRO
furkan
Pro Student 9,529 Points
var count = 0;

while(count != 26) {
     count ++;
    document.write(count);
  }

You forgot to increment (add on) a 1 to the count each time. Otherwise the condition would run unlimited times and wont stop because the count remains at 0.