Record Collection - (id, prop, value)

When we create the function, we write:

function updateRecords (id, prop, value) {

Are “id”, “prop”, and “value” KEYWORDS? For example, is it because of the syntax that the system knows “id” is our id number for each album?

Does the system know “prop” is the NESTED property? (Because the album ID numbers are also properties, but they are “first level” properties.)

I’m confused about how I would ever know this without copying what Quincy did. I mean, to use “id, prop, value” as the names of the parameters. The first condition in our if statement is “if(value === “”)” and I understand that this is saying “if the value is blank”, but how does the system know what “value” is? I mean, since “collection” is an object filled with objects, technically each nested object is also a “value”.

Any clarifying comments would be greatly appreciated :slight_smile:

Link to the challenge:

No, they are parameters of the function. Parameters are just placeholder variables that take on the value of the arguments passed to the function.

No, not like what you are probably thinking.

Because value is a variable just like other variables you have worked with.

collection is just an object. Objects have properties. Properties have values. In this case some of those properties are objects also.

1 Like

you could have written function (mushroom, banana, apple) {...} and it would have worked the same (if apple is an empty string do that etc), it makes most sense to use variable names related to what you are using that variable for

1 Like

Thanks for taking time to answer :slight_smile:

Thanks, yeah, that’s what I thought. I realized what was messing up my head. The instructions say “If value is empty, delete the given prop property” and I had been thinking that it meant if the value was empty in the array, but it meant in the parameters that we put in the function. Okay, that makes more sense now. I really appreciate that you took time to answer!

I worked through it. If anybody else has problems, I posted my solution and explanation here:

you could even make it better

and augment your comprehension of if/else statements
why the instructor did the if/else in that way?
what’s the difference with your code?

adding that would also make your article much more complete

Can you explain to me, how i would add a new id in this example?

the function is not equipped to add new ids

If you have a question about a specific challenge as it relates to your written code for that 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.