I just barely passed all the tests in Record Collection challenge. But i had to peek into other people’s codes to understand how to solve it. I still cannot understand why computer identify [id] as the “5439”, “1245” etc.
In previous challenges we accesed objects with direct names like “ourStorage.cabinet[“top drawer”].folder2”.
Why this sudden change to [id]?
Will this work with other codes the same way?
The last console log will return an error since you can’t access key of an object using a number. That’s invalid. However, the first console log works just fine. So one reason to use bracket notation is if you have keys of object that are not proper JS variable names.
Therfore you needed to use bracket notations to look at each object inside collection object because their keys were numbers.
When the function is called the things written in the parenthesis are passed in the function parameters, as such id is a variable that in this case has value 5439
I’m sorry but I still can not understand when id becomes 2548 , a prop becomes “artist”, and a value becomes as “Addicted to Love”.
For example, why if order of parameters changed function updateRecords(value, id, prop ) {...}
doesn’t work with updateRecords("ABBA", 5439, "artist" ); ?