Basic Solution you could add in this particular exercice -Data Structures - Check if an Object has a Property

Hi,

I was wondering on adding the ternary operator on the available solutions.
Since it could help on learning the syntax (by example) and since i also like to compare different solutions to improve my skills.

Sorry if this post is not in a good spot, i know that you guys did everything to not make us post proudly our solution.

Feel free to delete if necessary.

  **Your code so far**
Solution (Click to show/hide)
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) {
return (userObj.hasOwnProperty("Alan") && userObj.hasOwnProperty("Jeff") && userObj.hasOwnProperty("Sarah") && userObj.hasOwnProperty("Ryan")) ? true : false;
}

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/105.0.0.0 Safari/537.36

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

Link to the challenge:

I’m not sure I see a question in your post…

The thing is that it doesn’t need to be a ternary,

this already evaluates to true or false, so the ternary would just be extra noise

I would be against adding it as new solution to the guide

2 Likes

holy moly, i thought this was not going to work since i had to add something to make it work, mb then

Hello there.

Thank you, for your contribution. For future contributions, please wrap your solution within :

[details]
```
code goes here...
```
[/details]

Not a question, just thought that another solution was possible !
Mb on this, but soon i’ll be on your side, and helping other ppl

you can start anytime. If you know HTML, you can help with that or CSS or anything you feel comfortable helping with.

1 Like

I will start helping on thoses two for sure, since it was my main job while building wp website before :dancer:

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