Wrong solution on the video

In this exercise what you need to test if is obj contains checkpro, therefore the solution on the video is not correct.

This is my code:

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

}


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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36.

Challenge: Testing Objects for Properties

Link to the challenge:

Hey @Karem1986,

I couldn’t get it. My opinion is that the video is correct, and the video and your solution are the same, which both are correct.
Am I missing something? Could you be so kind as to explain in a little bit more detail?

Hi Yigi,

Look again at the video please, he uses checkpro and not obj,

please check again:)

It is not intended that you exactly copy the videos character for character. The content in the video is relevant, but the challenge has been updated since the filming of the video. This means that you need to read the challenge and think about how the discussion in the video can help you build the correct solution for yourself.

In this case, the challenge has been updated so that it does not use global variables. You generally want to avoid global variables when possible.

1 Like