11. And issues


#1


This code comes back as "Oops, try again. It looks like your function doesn't return false when hungry is false." and I have no idea why. I compared it to the previous answer and it looks the same. Can anyone spot the issue?

var hungry = true;
var foodHere = true;
var eat = function() {

    if (hungry && foodHere)
    {console.log("True");}
    else if (!(hungry || foodHere))
    {console.log("False");}
    else
    {console.log("You like neither?");}
};

#2

i see return, this usually means the return keyword is required, not console.log

also, you should return boolean values, not strings

if you need more help, can you post an updated version of your code and exercise url


#3

I changed the console.log to return, and removed the capitalization / quotes, and it's saying it's a syntax error.

var hungry = true;
var foodHere = true;
var eat = function() {

    if (hungry && foodHere)
    {return false;}
    else if (!(hungry || foodHere))
    {return false;}
    else
    {return "No Choice?";}
};

The lesson URL is
https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/2/2?curriculum_id=506324b3a7dffd00020bf661


#4

if hungry and foodHere are both true, return true

otherwise, return false. So you only need an if and else.


#5

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