Testing Objects for Properties Problems

Tell us what’s happening:
Describe your issue in detail here.
Hi Folks,
what’s wrong in my code ? Help me to pass this test. Thanks for your time.
Your code so far

var myObj = {
  gift: "pony", 
  pet: "kitten", 
  bed: "sleigh", 
  city: "Seattle"
function checkObj(obj, checkProp) {
// if(myObj.hasOwnProperty(obj)){
//   return myObj[checkProp];
// }

if(myObj.hasOwnProperty(checkProp) == true){
   return myObj[checkProp];

// if(myObj.hasOwnProperty(checkProp) === myObj.hasOwnProperty(obj)){
//   return myObj[checkProp];
// }
  return "Not Found";

  **Your browser information:**

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

Challenge: Testing Objects for Properties

Link to the challenge:

Why check if myObj has the property? The function is supposed to check obj.


Hi @raviprakash !

Welcome to the forum!

A few issues here.

You are not supposed to create your own object.
You can delete this.

You want to write a function that works with any object.
Not just one that you created. Or one that works only for the FCC tests.
What if I wanted to test my function with 100 different objects.

Then you would have to code out 100 different objects which is not ideal.

Which leads me to point no.2

Your task is supposed to check if obj has the property not myObj.

You need to use the function parameter of obj here

and here

once you make those changes then the test should pass.

Hope that makes sense!

1 Like

Wooo , Thanks for your time @jwilkins.oboe . finally, I have done with the test.

1 Like

thanks @JeremyLT , yes you are right. Done with the test.

Alguém sabe completar função de calculadora numero outrnumero operacao

1 Like

Hi @Ruaan !

If you have a question about a project I would suggest opening up a new topic.

Olá @Streetan!

Se você tiver uma pergunta sobre um projeto, sugiro abrir um novo tópico.

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