Testing Objects for Properties cours issue!

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function checkObj(obj, checkProp) {
// Only change code below this line
let result = obj.chekProp;
if(obj.hasOwnProperty("checkProp") == false) {
return "Not Found";
}

return result;
// Only change code above this line
}


  **Your browser information:**

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

Challenge: Testing Objects for Properties

Link to the challenge:

  1. checkProp is a variable, not an object property. Revisit Accessing Object Properties with Variables. Also, make sure you pass hasOwnProperty the variable and not a string literal.

  2. The variable name is checkProp not chekProp.

this was the right code

function checkObj(obj, checkProp) {

  // Only change code below this line

  if (obj.hasOwnProperty(checkProp)) {

    return obj[checkProp];

  }

  return "Not Found";;

  // Only change code above this line

}

I have blurred the code just to avoid spoilers.

But yes the code is passing. You do have an extra ; that shouldn’t be there, but otherwise good job.

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