Yusuf2
August 13, 2021, 10:58am
1
Tell us what’s happening:
Describe your issue in detail here.
Please help me in this Java course. It is saying obj not defined.
**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
return ["Alan", "Jeff", "Sarah", "Ryan"].every(name =>
obj.hasOwnProperty(name)
);
// 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/92.0.4515.131 Safari/537.36
Challenge: Check if an Object has a Property
Link to the challenge:
Hi @Yusuf2 !
Welcome to the forum!
Where did you define obj
?
Yusuf2:
obj.hasOwnProperty(name)
You probably meant to use the function parameter instead.
1 Like
Yusuf2
August 13, 2021, 11:05am
3
I defined it at number 23 typing that obj.hasOwnProperty(name).
That’s not how you define it.
That is what the computer is telling you.
It has no clue what obj is.
Besides, you are not using the function parameter.
That is what you need to use instead.
1 Like
This is the function parameter
Yusuf2:
(userObj)
But you are not using it at all.
Instead of using obj
which is not defined you need to use the function parameter.
make sense?
1 Like
Yusuf2
August 13, 2021, 11:15am
7
Please i might be disturbing you but i don’t understand. I’ve tried the parameter, it still doesn’t work. PLEASE! PLEASE!! PLEASE!!!
Can I see your updated code?
1 Like
Can you write in the forum what you tried using the function parameter?
When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
1 Like
Yusuf2
August 13, 2021, 11:22am
11
So what should i use it to do.
You mentioned that you tried using the function parameter but it didn’t work, right?
I want to see your new code so I can help you pass the test.
1 Like
Yusuf2
August 13, 2021, 11:25am
13
So I should reset the code.
I’ll try to explain the problem in a different way and maybe that will help you solve it.
You need to replace the word obj
here
Yusuf2:
obj.hasOwnProperty(name)
with the function parameter (userObj
)
functionparametergoeshere.hasOwnProperty(name)
Then the test will pass.
I am not allowed to give you full answers on the forum but hopefully that was a big enough clue on how to pass the test.
1 Like
Yusuf2
August 13, 2021, 11:39am
15
Thanks. It’s now done. I really appreciate.
I say a BIG THANK YOU to you and the forum. Lastly, THANKS! THANKS!! THANKS!!!
1 Like
system
Closed
February 11, 2022, 11:39pm
16
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.