Hi everyone! I just completed this challenge (https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/record-collection) with help from one post, but nevertheless there’s one thing remaning that I didn’t get.
if(prop === ‘tracks’ && collection[id][prop] === undefined) {
collection[id][prop] = [];//What does “[]” mean? I don’t get its purpose
** }**
Accessing element of an array e.g. arr[0] // returns 1
Accessing an object’s property
const myDetails = {
name: "Jane Doe",
age: 100
}
You can access name property using the syntax myDetails['name'].
But if i have an object nested within another object, you can use double square brackets.
Not really sure what you are asking here. If you want an array to push to, you have to create it first. So you make an empty array so you can push to it.
Here evenNumbers is the empty array that needs to be created so we can push to it.