QUESTION 06 / 20 · COMPARISONS · BEGINNER

The word false

What will this code print? Read each line, then make your prediction.

Where this matters

A checkbox value or stored text such as "false" is not automatically the boolean false. Treat external text according to its format.

JavaScript · read-only example
console.log(Boolean('false'));
console.log(Boolean(''));
Your prediction

Read the full explanation

Every nonempty string is truthy, regardless of its wording. An empty string is falsy.

Trace the code

  1. Boolean checks whether the string is empty, not whether its spelling names a boolean.
  2. The first string has five characters, so it is truthy.
  3. The second has no characters, so it is falsy. Even a string containing a space is nonempty.

Why the other predictions differ

  • true true — The empty string is one of the falsy values.
  • false false — Boolean does not interpret the English word false.
Expected console output
true
false

Reading this explanation does not record mastery. A correct submitted attempt can do so, including after review.

Change one thing

Compare a space with the boolean false to separate text from boolean values.

Predict the result, then run this self-contained snippet in your browser’s developer console. It uses only sample values and makes no network requests.

console.log(Boolean(' ')); console.log(Boolean(false));
Check the variation’s output
true
false

Explain which binding, value, or operation changed before moving to the next challenge.