Javascript: how to loop an array over and over again?
Go to solution
Solved by QQ_cazo,
Solved:
function gothru(array,data) { if (data) { console.log(array.id+"|"+array.parent_id) } else { console.log(array.id) } if (Object.keys(array.children_comments).length >= 1) { // i forgot that this was an ARRAY, so now it works for any number of comments. array.children_comments.forEach(element => { gothru(element,true) }); } } JSON.parse(a).forEach(element => { gothru(element) });

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now