Syntax question soloLoop()


Introduction to 'While' Loops in JS Lesson 6

Why does it need "soloLoop();" at the end? Why does the code even need var soloLoop?

I tried the code without it and it reads "Looped once! false" which seems like the result needed, especially as tha page says "Start Next Lesson" without any soloLoop variable.

    var condition = true;
var soloLoop = function(){

  while (condition){
      console.log("Looped once!");
  condition = false;



Do the instructions ask for a function called soloLoop?


Great questions! Good Software Developers always seek to understand the code! So you created a function and implemented it in this case, but did not call/invoke it. soloLoop(); at the end calls the function so the interpreter knows to use the code within the function soloLoop(); in the runtime execution of the program.


To Answer your 2nd question, its a bug on code academy, in the real js world, as you did not call the function, the code in the function would not be used. I look your your function offline to my atom editor which I code in js on. Not the outputs are at the bottom of the screenshots as follows:
Without the function call:

With function call:


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