I have trouble getting past lesson 11 of course 9, it is telling me that the value returns false when it should not be false


#1

Please, help! I have no clue what to do, I feel like I wrote the code right, but I get error messages.

The exercise is lesson 11 in 9. More on Control Flow in JS

Whenever the values are correct I get an error saying that the code doesn't return false when my first variable is false. When either variable is actually false, it asks if you set it to true. Please Help

// Declare your variables here!

var hungry = true;
var foodHere = true;

var eat = function() {
    // Add your if/else statement here!
    if (hungry && foodHere) {
        console.log("Let's eat!");
    } else {
        console.log("Let's not eat.");
    }
};

Thank you for your help!


#2

Nevermind, I forgot to add this:

eat()

#3

apparently still getting errors. the new code is as follows:

// Declare your variables here!

var hungry = true
var foodHere = true

var eat = function() {
    // Add your if/else statement here!
    if (hungry && foodHere === true) {
        console.log("Let's eat!");
    } else {
        console.log("Let's not eat.");
    }
};

eat()

Errors are the same, if I put "hungry = false" in the true section, I get the "Did you set hungry to true?" error.


#4

used an or operator(||) and got a true. got a false with an and operator(&&)


#5

I get a true and then a false. Okay, progress, but there is no hungry = false in the true section.


#6

odd. I added in a:

hungry = true

line and got the same result.


#7

My current code is:

// Declare your variables here!

var hungry = true
var foodHere = true

var eat = function() {
    // Add your if/else statement here!
    if (hungry === true && foodHere === true) {
        console.log("Let's eat!");
        hungry = true;
    } else {
        console.log("Let's not eat.");
    };
};

eat()

My console has this:

"Let's eat!"
"Let's not eat."

#8

if you need to return something, use the return keyword. See instructions when you need to return what


#9

I figured it out, eventually. Thanks though! Within minutes I figured it out. I felt so stupid. http://i2.kym-cdn.com/entries/icons/facebook/000/000/554/facepalm.jpg


#10