Could use Help with Record Collection Challenge

Do I need to create the array and then add to the array?

what condition does this snippet wants to satisfy?
what is each statement doing to that end?

as I said, check really really carefully

trying to satisfy this condition.

  • If prop is tracks but the album doesn’t have a tracks property, create an empty array and add value to it.

I think I see, I need to do the opposite of hasOwnProperty() right,? I need to see if it DOES NOT have certain property. How do I do the opposite of that?

what is it that you are checking to know if it has the property or not?

I think I missed some other issues with your code

what are you doing here?

Trying to create an array and add value to the created array.

but when you are doing it? what’s the condition?
when is value.length == 0 true, and when you want for that section to execute?

Wait. What? Why did value.length come back? This will make bugs. I thought you stopped using that above.

Is there a better way to check the length of an array? I did some googling and that came up as a way to check the length of an array.

It would be it would be true when the length of the array is 0.

But you aren’t checking the length of an array. value is not an array.

And you can’t check if an array is defined or not with this. If an array is not defined, then it won’t have a length property.

.length is only valid when you are trying to find the length of a string or array that you know exists/is defined.

Ok so I need to use hasownproperty() in the if statement?

That is how I would do it.

1 Like