Help please with this challenge

Modify the function checkObj to test myObj for checkProp. If the property is found, return that property’s value. If not, return “Not Found”.

This is my input below;

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

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

// Test your code by modifying these values

!!any help would be much appreciated.

You don’t have to check the object for only “bed” property,
You function should check for any property put as argument.
If the property is found, then return that property else return “Not Found”.
Does that help?

i tried var checkProp = myObj.hasOwnProperty(); but still not working

Use myObj.hasOwnProperty() inside if statement with checkProp as argument and that should help.

Hello, I’m writing from the phone and do not know the English one, so do not judge strictly…

var myObj = {
gift: 'pony',
pet: 'kitten',
bed: 'sleig'

function checkObj(checkProp) {
  if (myObj.hasOwnProperty(checkProp)) {
    return myObj[checkProp]
  } else {
    return 'Not Found'

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 easier to read.

Note: Backticks are not single quotes.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


1 Like

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

If you want to compare your solution to others, use the Get a hint button on the challenge and there are alternative solutions you can compare yours to. Also, you can probably search older posts using the forum search feature or google the challenge name and find more there.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

1 Like

Thanks man :+1: really appreciate the help.

1 Like