¿Puede estar roto el ejercicio?

Mi solución responde a lo que pide el ejercicio, pero además abajo te añade consigas como:
checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift") debe devolver la cadena pony .

No entiendo en absoluto a qué se refiere con todo eso. ¡Gracias!

  **Tu código hasta el momento**

function checkObj(obj, checkProp) {
// Cambia solo el código debajo de esta línea
if(obj.hasOwnProperty(checkProp)){
    return obj["checkProp"];
} else {
  return "Not found";
}




return "Change Me!";
// Cambia solo el código encima de esta línea
}
  **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/99.0.4844.82 Safari/537.36

Desafío: Verifica las propiedades de un objeto

Enlaza al desafío:

function checkObj(obj, checkProp) {
  // Cambia solo el código debajo de esta línea
  if (obj.hasOwnProperty(checkProp)){
    return obj["checkProp"];
  } else {
    return "Not found";
  }
  return "Change Me!";
  // Cambia solo el código encima de esta línea
}

console.log(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift"))

Have you tried looking at what happens when that command is run?

I get

undefined

so,

    return obj["checkProp"];

is an undefined value.

Lets look at your bracket notation.

checkProp is already a string, so you are getting the property called "checkProp", not the property that uses whatever name is stored in checkProp.

But if I put checkProp, without the quotation marks its the same. I really dont know what the exercise requests. Thank you for answer

What do you mean it is the same? What does your code look like when you do that?

You should have fewer failing tests when you remove the quotes.

Ahhh, ahaha the error was in “Not found”, the “f” was “F”. Thank you!

1 Like

Yup, that was the second one. Sometimes I only mention one error at a time.