In rule 2 and 3 I see that you used only if prop === tracks that passes is tracks different from prop? You are telling me to create an array but it will never enter that if if the only condition is that it be the same. and in the final part
it should not be? prop! == “tracks” && value! == “”
In the future, please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.
The easiest way to create a topic for help with your own solution is to click the Ask for Help button located on each challenge. This will automatically import your code in a readable format and pull in the challenge url while still allowing you to ask any question about the challenge or your code.
Thank you.
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.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
let’s consider what’s going on with your code:
you are checking if the object has the property, and if it has, you are overwriting it with collection[id].tracks = [], instead if the object has already the property you should just add value at the end of the array
if instead the object doesn’t have the tracks property, the second condition is the one that execute: collection[id][prop].push(value)
at this point, collection[id].tracks is undefined, so you get an error because push() works only with already existing arrays and the function stops.
is now clear why you are not getting the desired result?
@ILM Hi, I received a message from FCC that my post was flagged as inappropriate : the community feels it is offensive, abusive, or a violation of our community guidelines.
To inform you, I did not abuse anybody in the post (I never did in my entire life). Neither I was offensive, abusive or violected the community guidelines.
You did not like me posting a working solution and explaining it later thoroughly and I agreed to it. But telling me such things (that I was offensive) when I am clearly not. I do not like it. I kindly ask you please take it back.
Thank you for your concern, it was a misuse on my part on the moderator tools.
We are trying to cut back on the number of readily available solutions, to avoiding spoilers to people that are just trying to get hints from the Read-Search-Ask method, so they aren’t bombarded with clear solutions.
We also ask that you don’t share solutions just for the sake of sharing them, only if you have questions about a specific solution. And do not share solutions to people that ask for help, and instead point out what they did wrong.
If you think it is really important for you to share your solutions you can use the formatting options to hide it from first glance.