JavaScript básico - Verifica las propiedades de un objeto

Cuéntanos qué está pasando:
I just read all the posts for the resolution of this challenge and I changed as suggested in the comments but it still gives me an error when executing, when I type “city”, “gift” and “pet” it appears as if the string was not returned as it should be. I do not know what else to do
Tu código hasta el momento

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

function checkObj(checkProp) {
// Your Code Here

myObj.hasOwnProperty(checkProp);
return myObj[checkProp] || "Not Found";

}

// Test your code by modifying these values
console.log(checkObj("city"));
console.log(checkObj("gift"));
console.log(checkObj("pet"));

Información de tu navegador:

El agente de usuario es: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36

Desafío: JavaScript básico - Verifica las propiedades de un objeto

Enlaza al desafío:

Hola.

Te sugiero que primero reinicies el desafío ya que modificaste los parámetros de la función original.

En cuanto al desafío, se resuelve utilizando una declaración if/else:

if (condición) {
//si la condición es verdadera ejecuta este código.
} else {
//si la condición es falsa ejecuta este otro código.
}

En este caso tu condición seria algo asi:

obj.hasOwnProperty(checkProp)

Espero que con eso lo puedas resolver.

saludos

1 Like

Muchas gracias, estaba muy enredado en esta parte.

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