Console issue


How do I not show the word false in the console?

var greet = true; 
while (greet) {
    greet = false;


The full output of that code is:


It does not print false. So if false is printed, then something else did so. Your code does not have that behaviour, there is nothing to change. Ignore it.


That is a "feature/problem" of the console, not one of javaScript so when you run it somewhere else than a (web-)console you probably won't see this output.

What happens is just that the console echoes the last evaluated value unless it is used elsewhere. In this case the statement:

 greet = false;

as a whole has a value of false and that is printed.

So @king-jo if you want to get rid of it you could swap your console.log and the greet statement (they do not depend on each other so the order doesn't matter anyway) and then it should disappear because console.log has no value but just performs a job.

PS: But even though it might be confusing at times this "feature" of the console isn't harmful and will not show up when you work in anything else then a console e.g. a web page.

Why is "false" being logged?

Alright, thanks guys I was confused as to why codecademy's console showed 'false'.


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