I’m almost done with the exercise, but something isn’t quite right with my answer regarding the first else if where it says that records doesn’t have a tracks property. I used the hasOwnProperty method, because it, I assume, will come back as false. Then I am supposed to create an empty array. I don’t know if I’m doing it correctly.
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I think I got the hasOwnProperty method to equal a boolen false. However, I’m still stuck on how to create an empty array: I’ve done research to find out what an orphan and empty array are, tried multiple solutions but nichts.
Here you are modifying the value of records[id][prop]…
You are doing it here too…
So you should probably do that here too. This: records[id].hasOwnProperty('tracks') === false means that the records[id]["tracks"] doesn’t exist though, so the ‘create an empty’ array is talking about creating a value for records[id]["tracks"] before you try to add the value for this new track.
If you are still stuck, I suggest retrying the lesson.
I used to have the same problem as you did. I couldnt find a fully correct solution to this one. After some time retrying , I was able to arrive at the solution.
If you already tried again by resetting but you’re still not able to get it, try again!
Now you know a lot more about this topic than what you knew when you started. It should help. Good luck!!
This kind of tags on to some other comments, but I think refactoring without the use of && may lead to the solution. That is not to say you cannot use them, but just that it may simplify the logic and flow of things.
Never be afraid to write things simply. You can refactor and make more elegant later, if time and asks permit