10/11, to learn you gotta do it


I was able to get the system to accept my code as a pass, but I am not 100% sure why. I am sure this has been explained somewhere previously in the course, but I am having trouble tracking it down.

My code is:

var getToDaChoppa = function(){
// Write your do/while loop here!
do {console.log ("If you like cake then" + getToDaChoppa + "!")

}while (getToDaChoppa)};

and it prints nothing to console. Why is this a passing code, but it does nothing?


It is a function and function only run when they're called. As your function isn't called you don't see anything. But as it is callable the test function could let it run and there it seems to pass the test. Btw calling a function is done by functionName().

Just one last thing about your do while loop. Instead of getToDaChoppa here:

}while (getToDaChoppa)};

it would probably be better to use false or a variable that has a value of false. The function name should not serve this purpose or do you know for sure what the value of getToDaChoppa is?