Only half of the test is right: Testing Objects for Properties

Tell us what’s happening:
So I think there is something wrong with the if statement I am using
Although I am getting no errors the code seems to completly ignore the if block
I tested it out somewhere else
My 1st idea was that it was a type error since it may not recognize the string? and skip over it. but, then most likely a type error would show
then i found that i had not used checkProp and replaced it
but now only half the test is incorect so for some reason whatever is in checkProp is not check over correctly
I added my previouse code and the error message i got as well to this post

checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet") should return "kitten" .

Passed

checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house") should return "Not Found" .

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

}
  // Only change code above this line
}

Your code so far


function checkObj(obj, checkProp) {
// Only change code below this line
if (myObj.hasOwnProperty(checkProp)) ;
{

return "Not Found";

}

// 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/86.0.4240.111 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

I’ve edited your post for readability. 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 (’).

Neither checkObj nor myObj are obj.

1 Like

Thank I also realize that I did not return it right