Aesir
September 21, 2022, 1:10pm
1
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:
hbar1st
September 21, 2022, 1:27pm
2
I’m not sure I see a question in your post…
ilenia
September 21, 2022, 1:27pm
3
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
Aesir
September 21, 2022, 1:28pm
4
holy moly, i thought this was not going to work since i had to add something to make it work, mb then
ilenia
September 21, 2022, 1:28pm
5
Hello there.
Thank you, for your contribution. For future contributions, please wrap your solution within :
[details]
```
code goes here...
```
[/details]
Aesir
September 21, 2022, 1:28pm
6
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
hbar1st
September 21, 2022, 1:29pm
7
you can start anytime. If you know HTML, you can help with that or CSS or anything you feel comfortable helping with.
1 Like
Aesir
September 21, 2022, 1:37pm
8
I will start helping on thoses two for sure, since it was my main job while building wp website before
system
Closed
March 23, 2023, 1:38am
9
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.