Basic Data Structures - Check if an Object has a Property

Tell us what’s happening:
Describe your issue in detail here.
Umm, can anyone tell me what am I doing wrong here?
this is the challenge Check if an Object has a Property
Misson: Finish writing the function so that it returns true if the object passed to it contains all four names, Alan , Jeff , Sarah and Ryan and returns false otherwise.
Your code so far

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

function isEveryoneHere(userObj) {
  // Only change code below this line
  if (userObj.hasOwnProperty("Alan")){
    return true; 
  } else{
    return false; 
  }; 
  if (userObj.hasOwnProperty("Jeff")){
    return true; 
  } else{
    return false; 
  }; 
  if (userObj.hasOwnProperty("Sarah")){
    return true; 
  } else{
    return false; 
  }; 
  if (userObj.hasOwnProperty("Ryan")){
    return true; 
  } else{
    return false; 
  }; 
  
  // Only change code above this line
}

console.log(isEveryoneHere(users));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67

Challenge: Basic Data Structures - Check if an Object has a Property

Link to the challenge:

What would happen after checking existence of “Alan” ?
Your function immediately stops and return.

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