Solution of this exercise

Dicci cosa sta succedendo
Descrivi qui il tuo problema in dettaglio.

  **Il tuo codice fino ad ora**

function checkObj(obj, checkProp) {
// Modifica il codice solo sotto questa riga
if (checkObj.hasOwnProperty("gift")) {
  return "pony";
} else if (checkObj.hasOwnProperty("pet")){
return "kitten";
} else if((checkObj.hasOwnProperty("house")) {
return "Not Found";
}else if (checkObj.hasOwnProperty("city")){
return "Seattle";
} else if(checkObj.hasOwnProperty("district")){
return "Not Found";
} else if(checkObj.hasOwnProperty("gift")){
return "Not Found";
}



// Modifica il codice solo sopra questa riga
}
  **Informazioni del tuo browser:**

Lo user agent è: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36

Sfida: Verificare la presenza delle proprietà degli oggetti

Link alla sfida:

Excuse me, but I can’t solve this exercise. At beginning I type the cose as the solution you gave me, but free CodeCamp said me that I type as I made . :frowning:

You are not using the function arguments at all. You need to check if obj has the property checkProp.

Hi @tommaso.tiso !

I think it would be best to reset the lesson because I am also getting a syntax error when I test your code.

You can shorten your solution considerably.
You are not supposed to hardcode multiple conditions for the tests cases FCC provides you.

Your function should work for ANY object not just the ones FCC is testing you on.

Think of a shorter solution where you can say if the object has a specific property then return its value otherwise return Not Found.

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