Help with understanding Testing Objects for Properties

referring to “Learn Basic Javascript, Basic Javascript, Testing Objects for Properties”

In the lesson, it gives an example with a variable. In the practice part, it uses a function. i thought the function is followed by two values…

function checkObj(obj, checkProp)

How is one value a property of another value?
Can someone explain what concept I am not understanding?
Are they not values? If not, what do you label the parts of the function?

the parameter checkProp is the placeholder for whatever prop to be tested. So basically you want to test if the obj contains checkProp. And if it does, the value of that checkProp can be had by using some bracket notation. Hope that helps

Hello there,

For future posts, if you have a question about a specific challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

If you’re writing a function, the items between the parentheses could be anything you want. For example, I could write a function kind of like this:

function sayHi(name, priceOfTeaInChina) {
  console.log("Hi, " + name);

In this case, the checkObj function has these particular paremeters, one being the object to be checked, the other the property of that object you want to check. It would sort of be like writing:

//function that lets you choose a particular closet and a particular shoe in that closet
function shoeCost(closet, shoeType) {
  return (cost of shoeType in a particular closet)

or how about

//function that gets square footage for a particular room in a particular house
function getSqrFootage(house, room) {
  return stuff;
//the first parameter chooses which house. the second parameter chooses which room in that house.
1 Like