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

Kebafilwe Joseph Loiti
Kebafilwe Joseph Loiti
4,652 Points

Long Running Code.

I'm trying this challenge but its refusing and saying that my code took too long to run, plz help?

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

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 49,589 Points

You need to increment count inside the loop . Otherwise your condition to run, count < 26, is always true and you have an infinite loop. You can use count++ to increment by 1 each iteration.

Kebafilwe Joseph Loiti
Kebafilwe Joseph Loiti
4,652 Points

Thank you, i figured it out after posting and i got it