Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
let comparetable = [
        {
          id: "F75",
          name: "testuser1",
          type: "student",
          2022: [
            {
              subject1: 12,
              subject2: 12,
              subject3: 39
            },
            {
               subject1: 12,
              subject2: 12,
              subject3: 39
            }
          ],

          2021: [
             {
              subject1: 12,
              subject2: 12,
              subject3: 39
            },
            {
               subject1: 12,
              subject2: 12,
              subject3: 39
            }
          ],       
        },

        {
          id: "F756",
          name: "testuser2",
          type: "student",

          2022: [
              {
              subject1: 12,
              subject2: 12,
              subject3: 39
            },
            {
               subject1: 12,
              subject2: 12,
              subject3: 39
            }
          ],

          2021: [
              {
              subject1: 12,
              subject2: 12,
              subject3: 39
            },
            {
               subject1: 12,
              subject2: 12,
              subject3: 39
            }
          ]      
        },
]


What I have tried:

how to iterate nested array in tbody. here year only contain in array need to loop that in same table, i was tried out with initially i was iterate array and check object.key is array and then tried to loop in tbody .
Posted
Comments
Member 15627495 31-Jul-22 5:18am    
hello !

the array have a depth of 2.

a loop with one more loop in will do the job.

It's an associative array, using 'keys' and 'values'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900