Tell us what’s happening:
Describe your issue in detail here.
I have three questions.
① I can’t understand the meaning of 「records[id][prop] = value;」.
I know this part applies to “update or set that album’s prop to value .” in the instruction.
But I thought if I want to access the parameter 「prop」, I should type 「updateRecords[prop]」.
②I can’t understand the meaning of 「resords[id]」either. i think that’s because I don’t get the relationship of (records, id, prop, value). Why is only records black?
③ I don’t understand the difference between the third blue highlight and first. How does [value] work in this code?
I am shameful about the lack of understanding. I really appreciate if someone offers help.
but for number one:
look at updateRecords, what are its properties? does it have properties such as ‘tracks’, ‘artist’, etc, or are those on the inner objects?
And the property tracks within that record id can be accessed as: recordCollection['2468']['tracks']
In the updateRecords function, the value of records is recordCollection, the value of id can be 2468, the value of prop can be one of artist, tracks, etc., and the value of value can be any string, e.g., "some value".
NOTE that your code needs to be with the function updateRecords.
Thanks for your detailed explanation. However I can’t seem to be able to understand yet.
1.Are those arguments same hierarchy?
2. Why do we need [ id ] between records and [prop]?
These questions are haunting me…
There are two aspects to this question, I think, you need to know. First, how do you access the value of a property, for an object? Next, what is a function, and what are the various aspects of a function?
When you are clear about these, you will know more about the issue you are facing (and answers).
Hi, don’t know if you still need help, but your delete should come before push value. just like this
}else if (value === “”) {
delete records[id][prop]
}else if (prop === “tracks”) {
records[id][prop].push(value);
}
Thank you for following explanation. After posting here, I also asked about this in a different website. And then I got very clear diagram to understand the structure. So now I think I’ve got better understanding about this question.
To answer the first, I’ve learned that [id]and [prop]are in different hierarchy, meaning I have to use two .
For the second, I basically consider function as group of data. And its data can be changed by declaration.
I obviously know this understanding has lots of missing, but I just want to check if current state is in right direction.
The recordCollection is an object; a JavaScript object. In general, an object has properties and each property has a value.
PART 1:
let anObject = { prop1: "val1", prop2: 23 };
How do I access a property’s value? For example, let prop1Value = anObject.prop1;
Now the variable prop1Value has a value of "val1".
The same above statement can also be written using the bracket notation: let prop1Value = anObject["prop1"];