Https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property

I need to finish the second requirement.

let users = {
  Alan: {
    age: 27,
    online: true
  },
  Jeff: {
    age: 32,
    online: true
  },
  Sarah: {
    age: 48,
    online: true
  },
  Ryan: {
    age: 19,
    online: true
  }
};

function isEveryoneHere(obj) {
  // Only change code below this line
    
     
    if ( users in users===true)    {
              return true;
         }else{
           return false
         
      
         }
  // Only change code above this line
}

console.log(isEveryoneHere(users));

what’s the second requirement?
what’s the challenge code?

you can use the Ask for help button next time, and there is a precompiled post created, with already all this stuff

1 Like

The function isEveryoneHere should return true if Alan , Jeff , Sarah , and Ryan are properties on the users object.

That is what I can read and the code is up.

sorry, meant “what’s the challenge link?”

anyway, how do you check if an object has a certain property?
because doing users in users is not the way.
review previous challenges if you don’t remember

1 Like

It is the title of this: Https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-data-structures/check-if-an-object-has-a-property

Try taking each user that u need to check and put it into the if statement. Like this: "Alan" in obj, not like users in users.

1 Like

:frowning: . It does not work

I meant like this if ("Alan" in obj && "Jeff" in obj && "Sarah" in obj && "Ryan" in obj) then return true, and after that you put else statement that returns false.

It does not work neither

Paste the code here and i will tell you what is wrong with it.

function isEveryoneHere(obj) {
  // Only change code below this line

if ( "Alan" in obj && "Jeff" in obj && "Sarah" in obj && "Ryan" in obj in obj==true)    {
              return true;
         }else{
           return false
         
      
         

         }
}

console.log(isEveryoneHere(users));

remove in obj==true from here: ( "Alan" in obj && "Jeff" in obj && "Sarah" in obj && "Ryan" in obj in obj==true). If statement will automatically return true if everything checks out.

1 Like
let users = {
  Alan: {
    age: 27,
    online: true
  },
  Jeff: {
    age: 32,
    online: true
  },
  Sarah: {
    age: 48,
    online: true
  },
  Ryan: {
    age: 19,
    online: true
  }
};

function isEveryoneHere(obj) {
  // Only change code below this line

if ("Alan" in users &&"Jeff"in users  && "Sarah"in users &&"Ryan"in users  ==true)    {
              return true;
         }else{
           return false
         
      
         

         }
}

console.log(isEveryoneHere(users));

Thanks!

1 Like

You still could remove ==true part and it would work, because it will automatically fire if everything checks out. No probs m8, happy coding! :slightly_smiling_face:

1 Like

I am thankful for yor time.

1 Like

I am thankful for yor time