Ejercicio: Verifica las propiedades de un objeto

// Establezco la variable
var myObj = {
gift: “pony”,
pet: “kitten”,
bed: “sleigh”,
city: “Seattle”
};

function checkObj(obj, checkProp) {
if (myObj.hasOwnProperty(checkProp)) {
return myObj[checkProp]}
else {return"Not Found"}
};

Necesito ayuda con este ejercicio, nose porque me pide que en un momento gift sea igual a pony y en otro momento que gift sea igual a not found.
No se la manera en la puedo hacer eso, ayuda porfavor.

checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift") debe devolver la cadena pony .

checkObj({pet: "kitten", bed: "sleigh"}, "gift") debe devolver la cadena Not Found .

Estas dos cosas me pide.

Inside your function you are using myObj. You should not be using that, it should not exist. you should be using the object that is passed into the function.

1 Like

Still not understanding, i keep trying but it doesnt work

Can you provide a link to the challenge so we can provide a more concrete explanation?

Its okey, i already made it right, thank you!

1 Like