#12 I have no clue about this

// Declare your variables here!

var tired = true;
var bored = false;

var nap = function(tired, bored) {
// Add your if/else statement here!
if(tired || bored === true){
return true;
return false;


What you have to realise…
#####.is that, after starting your Browser you are entering the so-called
#GLOBAL-scope . . .GLOBAL-bubble
######and as you execute a FUNCTION, the code in the FUNCTION-BODY is executed in it’s
#LOCAL-scope . . . . LOCAL-bubble
In this exercise you are declaring 2 variables in the GLOBAL-scope (outside of the NAP-function )

var tired = true;
var bored = false;

you can define a =function= which takes NO parameters

var nap = function() {
              //Begin of FUNCTION-BODY you are in the LOCAL-scope

and from within the FUNCTION-BODY / LOCAL-scope you can reach out, into the GLOBAL-scope
where you can get access to Boolean VALUES of the variables tired and bored

Now read the FUNCTION talk is in a separate POST

Now you defined the nap =function= as having 2 parameters tired and bored
as these tired and bored parameters
are used as tired and bored LOCAL variables
you will NOT have access to the GLOBAL variables tired and bored
as you are calling the nap =function= which has 2 parameters defined
you will have to provide 2 arguments,
otherwise the tired and bored varaibles within the LOCAL-scope are undefined

Create the nap =function= with NO parameters.


google search
== the Book ==
javascript [your question] site:developer.mozilla.org
javascript logical operators site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com

== guidance ==



the FUNCTION talk

var myFunc = function( param1, param2) {
       //Begin of  anonymous FUNCTION-BODY
       //VARIABLE -myFunc- has an -anonymous function- assigned
       //this -anonymous function- has 2 PARAMETERS param1 and param2
       //param1 and param2 PARAMETERS are used 
       //as -local- VARIABLES throughout the FUNCTION-BODY

      console.log( param1 + " and " + param2 ) ;

      //End of anonymous FUNCTION-BODY

If you want to call/execute the anonymous function
you will have to add a pair of parentheses to the variable myFunc
As the anonymous function was defined
as having 2 parameters
you have to provide 2 arguments
in our case 2 string VALUES “Alena” and “Lauren”

some quotes from the outer-world:

argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block


"parameters" are called “formal parameters”,
while “arguments” are called “actual parameters”.


function with 1 parameter using return-statement

var myFunction = function( param1 ) {
       //Begin of FUNCTION-BODY
       //myFunction =function= has 1 PARAMETER param1
       //this param1 PARAMETER is used as a -local- VARIABLE
       //throughout the FUNCTION-BODY

      return param1;

      //End of FUNCTION-BODY

you have defined a myFunction function
which takes 1 parameter param1
this param1 parameter is used
as a variable throughout the FUNCTION-BODY.

If you want to call/execute this myFunction function
and this myFunction function was defined
as having 1 parameter param1
you will have to provide 1 argument
in our case a “number VALUE” 4
myFunction( 4 );

some quotes from the outer-world:

argument is the value/variable/reference being passed in,
parameter is the receiving variable used within the function/block


"parameters" are called “formal parameters”,
while “arguments” are called “actual parameters”.


As you are using the return-statement in your myFunction function
you will only get a return-value no-display.
You can however capture this return-value in a variable
and then use the console.log()-method to do a display.

var theResult = myFunction( 4 );
console.log( theResult );

OR directly

console.log( myFunction( 4 ) );

Thanks @leonhard_wettengmx_n for going into so much detail, that really helped.

The instructions says to: Create two variables, tired and bored, and set one equal to true and the other equal to false. (It doesn’t matter which is which.) Inside the nap function, create an if statement that returns true if either tired or bored (or both!) are true, and false otherwise.

var tired = true;
var bored = false;

var nap = function() {
if (tired && bored || tired || bored) {
return true;
else {
return false;

The code reads, if var tired and var bored are both positive OR if either var tired OR var bored are positive, return true, otherwise return false.

1 Like

remove the ; do the same for false

@stanlo Actually OR (||) is already an inclusive or meaning that all these cases are true:

true || true true || false false || true

so instead these 3 parts you’d just need

tired || bored

In your case you really need to be careful about the operator precedence to see in what order the statement is evaluated. Here it should work because && gets evaluated before ||.

So is there really a problem with your code or did you just want to get feedback about it?

PS: (Warning: Advanced content) If you want to have an exclusive OR meaning the natural usage of either that one or the other (not both). Than you could do the trick of using the bitwise XOR (eXclusive OR)

true ^ false

but this really only works for boolean values because it actually is cheating as what it really does is comparing two binary numbers and giving 1 if the bits are different and 0 if they are equal. Here’s an example:

num 1:     1 0 1 0
num 2:     1 1 1 0
result:    0 1 0 0

so as you can see 0 XOR 0 is 0, 1 XOR 1 is 0 but 0 XOR 1 is 1 aso. So if you’d enter 10 (1010) ^ 14 (1110) you’d get 8 ( (0) 1 0 0).

Now as true has a value of 1 and false has a value of 0 you can build an XOR by using the bitwise XOR operator ^. If this is two complex at this point just ignore it for now as said that would be advanced content.

@webninja12835 That semicolon is perfectly fine.

Thanks. Quite advanced insight.