Javascript While Loop


Hi everyone, I'm a beginner, I'm having trouble with making this while loop (Javasript) work, its for the exercise in the link below.
Please help me know where I'm writing it wrong or with a better alternative while loop. Thank you.
The code I'm using is:

//Remember to make your condition true outside the loop!

var soloLoop = function(myNumber){
  //Your code goes here!
  while(myNumber<=5) {
      console.log("Looped once!");


PS: I also tried changing the word 'soloLoop' below the console.log to 'myNumber' but that dint work either.


You need to create an initial condition that is true, for example:

var hiHo = true;

and then do your while loop simpler, like this:

var soloLoop = function(){
      console.log("Looped once!");
      hiHo = false;

ths code tells the computer that as long as var hiHo true, it should execute the while loop
thus, hiHo becomes false and the while loop no longer runs, only logging "Looped once!" ONCE.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.