Boolean Error


When I give the boolean value as ‘false’, it displays the output, if I give as ‘False’, it throws out an error,
Boolean is just the value to be true/false right, is it case-sensitive even in this case?

<Below this line, add a link to the EXACT exercise that you are stuck at.>
Error on 2.Types

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

var myBoolean = False;

ReferenceError: False is not defined
at Object. (/home/ccuser/workspace/javascript_101_unit_1_v10/types.js:3:17)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)
at bootstrap_node.js:542:3


var myBoolean = False;

<do not remove the three backticks above>



JavaScript is Case Sensitive. Thus, you get the error
ReferenceError: False is not defined

On another note, variable var myBoolean is not the same with var MyBoolean or var myboolean. It has to be matched exactly, spelling and case-wise.

If you’re referring to boolean value, there are only two: true or false.

If you want to use False, you have to wrap it with quotation marks, like

var myTesting = "False"

But remember, "False" is then a string value not a Boolean value.


when False itself is a variable, like:

var False = 3;
var myTesting = False;

This means you can assign False without quotation marks to var myTesting,

However, usually in the practice, it’s best to avoid using true, false, for, else, if … etc those terminology in JS as variable names in order to escape confusion and unwanted errors.

Hope it helps.:slight_smile:


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