Checking a property in an object

Hello guys! I am confused about this function. Is it ok to create a function with a parameter but not using the parameter inside the function?
Can someone explain me this function. Thanks a lot!

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) {
  // change code below this line
  if(users.hasOwnProperty('Alan','Jeff','Sarah','Ryan')) {
    return true;
  }
  return false;
  // change code above this line
}

console.log(isEveryoneHere(users)

You can put as many parameters as you like in, you don’t need to use them, but it’s a bit pointless (not to mention confusing).

Note this code here just won’t work (for related reasons) — hasOwnProperty uses one argument, so everything after ‘Alan’ will just get ignored (again, it’s a function, you can specify as many arguments as you want, doesn’t mean they’ll be used though)

Edit: Is this from the example solution when you click get a hint? Because it’s not good and not a solution

1 Like

Right now it works to check users and not obj, because its in the global scope. But I would recommend using parameters because otherwise the code can get out of control quite fast.

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

If you want to compare your solution to others, use the Get a hint button on the challenge and there are alternative solutions you can compare yours to. Also, you can probably search older posts using the forum search feature or google the challenge name and find more there.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

1 Like

Understood.
And yeah you are absolutely right!

1 Like