Record Collection - hasOwnProperty confusion

I felt like I was so close to solving the record collection problem but I’ve found myself mired down and going in circles. I feel like I’m making reverse progress at this point.

It’s all concerning the hasOwnProperty method. I’m trying to solve for the line, " If prop is "tracks" but the album doesn’t have a "tracks" property, create an empty array before adding the new value to the album’s corresponding property."

The code I had written for that didn’t seem right and so I was trying to get the syntax correct by writing snippets containing boolean statements, trying to find something I will know how to plug into the function. At this point, I’m having problems even targeting object properties correctly.

Why is this returning nothing but errors?

function hasTracks(id) {
  if ('tracks')) {
    console.log('This ID has tracks');
  } else {
    console.log('This ID does not have tracks');

You can’t use dot notation with variables, id is a variable with a numeric value, but like that it is trying to access the property called "id". You need to use bracket notation

1 Like

This helps a lot! I’m over one hump now.