Codes for assignment And


var hungry=true;
var foodHere=true;

var eat = function(hungry, foodHere) {
// Add your if/else statement here!
if(hungry && foodHere=true){
return true;
return false;


1. The instructions say that your function eat should not take an input. Remove hungry, foodHere from your function's input parameter so that it looks like this: var eat = function() {. It doesn't need an input because we do not need to supply it with new data. The function only needs the data for hungry and foodHere which has already been declared in the global variables.

2. Your if condition should not include the statement =true. The && alone asks if both items are true, and because you already declared a global variable for hungry and foodHere with a value of true, (hungry && foodHere) will suffice.

Happy coding!


also = true would mean setting the variable to be true not checking it's value.