Can't do Testing Objects for Properties

The function has parameters, obj and checkProp

these parameters get a value when the function is called with some arguments.

When the function is called, for example with

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

obj is assigned a value of {gift: "pony", pet: "kitten", bed: "sleigh"}
and checkProp is assigned a value of "gift"

Maybe you need to redo the previous challenges, make sure you understand each one you go through

If you have issues understanding, please take the time to ask explanations on the forum

Ok, its amazing you got as far as you did without ‘getting’ variables. Variables are a critical idea. You can’t do Javascript without them.

Data is stored in variables:

const someNumber = 42;
const aName = "bob";
const thisIsAnObject = {bob: 42};

You can pass data into a function, and then those arguments become variables

function printSomeStuff(name, age) {
  console.log("The variable name = ", name);
  console.log("The variable age = ", age);
}

printSomeStuff("bob", 42);

Calling the function determines the values of the arguments.

The tests are going to call checkObj and set the values of obj and checkProp for that function call. But, the specific values that the test suite will use have nothing to do with the code you have to write for this challenge. Your code needs to work for any object obj and property name checkProp.

1 Like

You may notice the list of the tests that fcc performs on your solution to check if it is correct or not:

Roughly speaking, the site is calling your function with different inputs and check corresponding outputs to determine if they are correct. And if they are, then you pass the challenge.

2 Likes

I know they store data, I know they can be declared. I know the difference between const, var and let–and how that makes them subject to change or not.

I just can’t get my brain to put these things together when the lessons get complex. Or if something is phrased differently.

I think I will re-do everything from the start because I just can’t work out why I have such huge gaps in understanding.

I used to look at the answers a month ago, but stopped. But I didn’t realise it was still messing up my learning process so badly still weeks after.

I’m sorry for taking up everyone’s time.

did you complete again those challenges without looking at the solutions?

…those are the ones I’m really stuck on and have been trying to do including this one.

Ok. obj is a variable. checkProp is also a variable. You need to treat them like variables to accomplish this challenge.

This challenge has 3 parts

  1. Check if obj has the property given by checkProp

  2. Return the value of the property checkProp for the object obj if it is defined

  3. Return the default message if the property is not defined for this specific obj

I don’t think I can do this lesson sorry.
It turns out I can’t do Passing Values to Functions with Arguments that I need to understand to do this lesson.

I think I was thinking of another lesson that I managed to complete.

I’m not ready for this one and can’t do it sorry for using everyone’s time again.

I’m not trying to be annoying or waste time I just really find Javascript hard and keep over estimating how much I can do or am ready for.

I’m really sorry about this again.

As an offtop. You are not wasting anyone’s time. I am having fun myself by answering questions and helping others completely voluntarily.

3 Likes

This stuff is hard. The whole reason why people come to this forum is to learn and help people learn. Asking and answering questions is never a waste of time - its the whole purpose

3 Likes

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