Ch. 12 Or / Should This Not Return True Instead of False?


So if the || operator evaluates to true if one or both of the expression are true then should this code not return true instead of false? The expressions tired is set to true. The if function returns true if (tired || bored) are evaluated as true, which according to this lesson, they should be. I instead receive false. Why is this?

tired = true
bored = false

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


Because one operand is true, the expression is true, so the return will be true.


I'm not sure you answered my question. I receive a return of false. Through my logic, this tells me that (tired || bored) is false since the code is executing else and returning false. Yet, based on the lesson's information (tired || bored) should be true, and therefore execute the first action in my if statement, i.e. return true.



Actually, the code is not running because it hasn't been called. You're see the console logging of the last assignment, bored = false.

Be sure to call the function,



Can you give me an example of how calling the function in this particular instance would be written in code?


The above line would be written after the function definition.

var nap = function () {




Okay, that works. Thank you! This lesson is misleading to the student. The code does not execute correctly unless the function is called, yet the lesson grants a 'Success' even when the function is not called. I'm not sure if you are in a position to correct this, but I thought I would let you know anyhow. Thanks again.


We're none of us able to fix the old courses as their editing suite is gone. The courses are essentially archived and will remain in their current form.


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