Answer the question
In order to leave comments, you need to log in
Recursive search in an array of objects?
Hello.
There is an array with objects, each of the objects is a comment record. Each object can have a nested object (reply to a comment). Each object has the same structure, each has the "Rating" property
Task: write a function that finds the required comment in the array by the given id and changes its rating (+1 or -1 depends on the second parameter in the function)
Tried to build a recursive search, but failed. Most likely, the algorithm was built incorrectly.
What could be the mistake, where did you make a mistake and what should be rewritten?
Sandbox attached: https://jsfiddle.net/gm2xz9bq/3/
Thanks
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question