More on Control Flow in JS - Or. Error message


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-qDwp0/2/3?curriculum_id=506324b3a7dffd00020bf661

I am getting an error message and both strings printing to the console when I have one true and one false, however when I have either both true or both false I am getting the proper single response. What am I missing? I tried command+r to refresh my browser but that doesn't make a difference.

this is the error message:

Oops, try again. It looks like your function doesn't return false when tired and bored are both false.

var tired = true;
var bored = false;

var nap = function() {
  if (tired || bored == true) {
      return('get some rest!');
  } else {
      return('doing great!');
  }
  
}
nap();


#2

so I'm not sure how this will effect the code but my code didn't include == true. I'm pretty sure this is because when something is in the condition it is already checking if its true. also your return statements don't need parenthesis. otherwise your code should be fine


#3

oh i almost forgot, the instructions are asking for you to return false, not a string. so instead of get some rest and doing great, you should have true and false without " " ' '


#4

awesome!, thanks kalebmfratelo, that worked. I must have misunderstood the instructions. I appreciate the quickness of your help!


#5

no problem. I like to watch for new posts so I can help as soon as possible. I hope you enjoy the rest of the course!


#6

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