Operator &&


how do you do this instructions?

Create two variables, hunger and nourritureIci, and give them to true. In the function room, create an if statement that returns (return) true only if hunger and nourritureIci are both true, and false otherwise. The dining function will take two parameters - and hunger and nourritureIci - which must both be global variables.

me i realized this code for this instruction:

var hunger = true;
var foodhere = true;

var eat = function(fain, nourritureIci) {

if (hunger && foodhere) {
  return true;

  else if (hunger && foodhere){

    return false;





Show me your code so i understand . think!


you dont need else if here.
If you have more than one condition then you should use else if
i cant understand why did you set condition like this.it doesn't make snese.

if (hunger && foodhere) {
  return true;
else if (hunger && foodhere){
 return false;

In your code both condition are same.but you want different result.how could it possible?
you should use different condition and different result.isn't it?
if first condition doesn't match then it'll check next one .
so your code should be like

if (hungry && foodHere) {
        return true;
       } else {
          return false;

and read the instruction again :slight_smile:
The function eat should take no input

so remove fain, nourritureIci from
var eat = function(fain, nourritureIci) {

i hope u've understand :slight_smile:


parameter are in french but in english that (hunger,foodHere)


can you please give me the lesson link ?


ok https://www.codecademy.com/en/courses/javascript-beginner-fr-FR-b3xz8/2/3?curriculum_id=5355c2b7516bcbd912000008


you gave me wrong link. i am talking about this lesson

in that lesson your code should be like

// DĂ©clarez vos variables ici !

var manger = function() {
    // Ajoutez votre déclaration if/else ici !
if(faim && nourritureIci ){
    return true;
        return false;

did you pass this lesson?


no i win this lesson and i pas then . Your answer was too long. But thinks!


hii,m having a problem in the code,though i think i have written it correct.here it is -

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

it is showing the error- Oops, try again. It looks like your function doesn't return false when hungry is false.what actually is it trying to say?


In your return statements, you are returning text strings "true" and "false" . The instructions expect you to use boolean values true and false (without quotation marks).


From the error instruction, it seems that you are supposed to give hungry the value of "false" while foodHere is given the value of true.
Declare this...
var foodHere = true;
var Hungry = false;

biff75 may be correct, but i'm only answering based on the error massg you gave.

also like biff75 said remove the quotes. You're required to enter a boolean not a string.


okk..yao i got my mistake...thnxxx


nopes...in instructions it is mentioned to declare both variables with true...bt thnxxx...