JavaScript Testing objects for properties exercise n.91

The question is simple: why the example is in a way then is asked to something else?

function checkObj(obj, checkProp) {
// Only change code below this line
gift: pony,
pet: kitten,
bed: sleight
checkObj.hasOwnProperty ("gift");
if (obj.hasOwnProperty ("gift")) {
return obj ["pony"];
} else {

return "Not found";
// Only change code above this line
  **Your browser information:**

User Agent is: Mozilla/5.0 (Linux; Android 6.0.1; P01T_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Safari/537.36 (Ecosia android@88.0.4324.181)

Challenge: Testing Objects for Properties

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Hi @lineup475 !

The example code is meant to show you how the basic concept works.

In this code here

const myObj = {
  top: "hat",
  bottom: "pants"


This is to show you how to use the hasOwnProperty method to checking if a property exists.

In this challenge, you are not supposed to create your own object.
Instead, you need to create a function that checks if a property exists or not.
If it is exists then return that property’s value otherwise return “Not Found”.

It is not asking you to do something else.
It is just the answer is not nearly identical to the example code.

There are challenges, where you can just copy the example and change one small thing.
But in my opinion, sometimes people just end up copying the examples without really understanding how it works.

Hope that helps!

1 Like

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