Skip to content
Advertisement

traverse through nested children of an array of objects and make a property equals false – JavaScript

I have a tree, that I want to traverse through. I want to make each internalChecked = false. I wrote some code, but failed.

Tree

JavaScript

Advertisement

Answer

You are pushing every json chunk in an output array that makes the output different than it is, just use __json[i].internalChecked = false in your loop and it will update the array on which you are iterating on:

JavaScript

Also, if clause,

JavaScript

can be simply

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement