Javascript:Testing Objects for Properties`

Javascript:Testing Objects for Properties`
0

#1

Hi,
Still stuck with this one let try with this,

// Setup

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

function checkObj(checkProp) {
  // Your Code Here
  var propname;
if(myObj.hasOwnProperty(checkProp)== true){
  return myObj[checkProp];
}
  else{
    return "Not Found";
  }
}


// Test your code by modifying these values
checkObj("gift");

#2

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Also, since your solution does actually pass all the tests, I blurred it out by surrounding your code with [spoiler] and [/spoiler]` tags.

You may need to refresh your browser and then run the tests again, so your solution will show passing.