6. Solo Fight - Is the false statement supposed to show up in the box?


#1

Here's my code:

//Remember to make your condition true outside the loop!
var count= true;

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

soloLoop();

I did it correctly, but I'm wondering if the false statement is supposed to show up? I tried doing it without the code being in a function variable and the false statement shows up without me putting it in the console.log!


#2

Yes the last value in the code that is not used by another statement is printed to the console. If you want to get rid of it just swap this statement with the console.log as console.log has not value itself and "consumes" the value in it's parenthesis. Also outside of the loop does not mean outside of the function so maybe put that var count = true inside as well, otherwise your soloLoop function will only work once because after this count is false (globally).