How to Change value of nested array objects in javascript

I want to change the checked value base on the id kindly help me to solve this.I’ll pass an id which have to match in each object in sub_cat and if any result found then change the check value

  "data": [
            {
                "id": "1",
                "name": "Electrical Repair & installation",
                "parent_id": "0",
                "image": "assets/images/Group66.png",
                "checked": "false",
                "sub_cat": [
                    {
                        "id": "7",
                        "name": "Sockets",
                        "parent_id": "1",
                        "image": "assets/images/Group66.png",
                        "checked": "false"
                    },
                    {
                        "id": "8",
                        "name": "Fans",
                        "parent_id": "1",
                        "image": "assets/images/Group67.png",
                        "checked": "true"
                    }
                ]
            },
         
           
        ]
  

24 thoughts on “How to Change value of nested array objects in javascript”

Leave a Comment