Testing Objects for Properties_code not working

Testing Objects for Properties_code not working
0

#1

Hi
I’ve been at this for a couple hours and the tests pass for the properties that exist
However, I get an error when I try to pass a property that doesn’t exist instead of the false path which should return Not Found?
Can anyone spot the error?
Thanks

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  var prop = myObj.hasOwnProperty(checkProp);

  if (prop = true){
  return myObj[checkProp];
}else{
return "Not Found";
}
}
// Test your code by modifying these values
checkObj("gift");

#2

Don’t use assign operator use comparison operator.


#3

Thanks
Now that you mention it I saw it right away :wink: