Estou tendo dificuldade em passar neste desafio, alguma dica?

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

function checkObj(obj, checkProp) {
// Only change code below this line
return "Change Me!";
// Only change code above this line
}
  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0

Challenge: Testing Objects for Properties

Link to the challenge:

Tens que fazer em varios passos:

  1. verifica que obj.hasOwnProperty(checkProp) e verdade
  2. se sim devolva obj[checkProp];
  3. caso nao devolva “Not Found”
1 Like

Sera que os objectivos devo criar dentro da função checkObj?

isso mesmo. se continuas a ter dificuldade mostrame o teu codigo

Olá, @talesscof ! Bem-vindo ao fórum do freeCodeCamp.
A sequência para a resolução do desafio é essa mesma que @damianicely forneceu.

A sequência é condicional e vai dentro da função checkObj.

Caso tenha outras dificuldades com os desafios, avise-nos que tentamos solucionar por aqui. Boa sorte e boa programação.

Esta tudo compilando certo mas, ainda assim nao passo no exame.

function checkObj(checkProp) {
// Only change code below this line
const myObj = {
gift:“pony”,
pet: “kitten”,
bed: “sleigh”
};
if (myObj.hasOwnProperty(checkProp))
return console.log(myObj[checkProp]);
else
return “Not Found”;
// Only change code above this line
}
checkObj(“house”)

I can passed in this test, my solution

const Obj = {
gift:“pony”,
pet: “kitten”,
bed: “sleigh”
};
function checkObj(Obj,checkProp) {
// Only change code below this line

if (Obj.hasOwnProperty(checkProp))
return Obj[checkProp];
else
return “Not Found”;
// Only change code above this line
}
checkObj(“house”)

Obrigado pela ajuda malta

1 Like