Review


#1

I have written the simplest while loop imaginable. I don't know why the console prints out "Hello" and then "false". I understand why it prints hello but console.log is never set to false.

while(condition) {
console.log("Hello");
//avoid infinite loops
condition=false;
};


#2

This is Codecademy's code checker printing false.

The best way to separate your logs from Codecademy's is to add:

console.log("Everything below is random junk! :)");

After all of your code.


#3

Probably just codecademy checking if your variable's value is correct by printing to the console.


#4

No at least this time it’s not codecademy’s SCT :slightly_smiling:
The “problem” is that you run your code in some sort of web console. Which has the advantage that you do not need to bother with HTML+CSS, DOM and window for now and can just write your code and execute it in the console. But which also has the disadvantage that consoles have a life of it’s own. You can test this in firefox’s or chromes web console as well so it is not just limited to codecademy.

But to the topic the reason why you see the false is because the console gives you a quick echo of the value of the entered code. If you enter just “test” you’ll see ‘test’ written in the console. Do not confuse this with an output it is just an echo and if an exercise requires you to console.log something this will not count. Yet it is useful when you just use functionCall() and see a result without the explicitly using console.log. For longer snippets of code the last unused value is shown this way. And this applies only to values the default non-value undefined is not shown, so as console.log itself has no value (undefined) using @cadecodes solution of adding a console.log at the very end of your code actually works. But if you know about it, it might even be useful to get a quick response that everything worked well.
What you could do as well is run the code in:
labs repl.it
it has the old design and there the console echo is => green text whereas the regular console.log is white.