Basic JavaScript - Testing Objects for Properties

Tell us what’s happening:
Describe your issue in detail here.
The question is not clear. Even the explanation in the hint are not clear. I just copied the answer and moved on because the question contains concepts that are not yet covered.
Your code so far

function checkObj(obj, checkProp) {
  if (obj.hasOwnProperty(checkProp)) {
    return obj[checkProp];
  } else {
    return "Not Found";
  }
}

Your browser information:

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

Challenge: Basic JavaScript - Testing Objects for Properties

Link to the challenge:

obj.hasOwnProperty(checkProp) simply checks if an object (obj) contains a property (checkProp), and returns a boolean (true or false). Note that obj and checkProp are simply parameters passed to the function.

If true, the conditional statement returns the property’s value (using bracket notation as it’s a variable). (Dot and bracket notation has already been covered iirc).
That’s all there is to it.

That said, we shouldn’t post working solutions to the forum, so please surround the code with [spoiler]code here[/spoiler] tags.

Modify the function checkObj to test if an object passed to the function (obj) contains a specific property (checkProp). If the property is found, return that property’s value. If not, return "Not Found".

The question is clear if you know what all of the technical words mean. If you forget the meaning of these words that were introduced in previous steps, then this challenge is much harder. You should ask questions if you don’t know what words in the instructions mean. This stuff is hard and takes practice.

Can you delete the entire thread? Thank you.

The post was written with blunt words and I want to take my time to check the topic again and if I still don’t understand it I will redo the post.

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