Home » Jquery » javascript – how to loop through the array object

javascript – how to loop through the array object

Posted by: admin February 22, 2020 Leave a comment

Questions:

I have the below code that is coming from a Sharepoint list. I am not able to loop through the array object. Could anyone please help me to find out how to do this.

I want to use accordion. First I want to display the number 4 and then on the click of the number 1 it will open a accordion that will display the internal array.

{
  "1": [{
    "groupDateArray": 1,
    "groupCurrentID": 6,
    "groupOnlyDate": "1/30/2020"
  }],
  "2": [{
    "groupDateArray": 2,
    "groupCurrentID": 17,
    "groupOnlyDate": "2/26/2020"
  }, {
    "groupDateArray": 2,
    "groupCurrentID": 20,
    "groupOnlyDate": "2/20/2020"
  }, {
    "groupDateArray": 2,
    "groupCurrentID": 19,
    "groupOnlyDate": "2/20/2020"
  }, {
    "groupDateArray": 2,
    "groupCurrentID": 21,
    "groupOnlyDate": "2/14/2020"
  }, {
    "groupDateArray": 2,
    "groupCurrentID": 16,
    "groupOnlyDate": "2/11/2020"
  }, {
    "groupDateArray": 2,
    "groupCurrentID": 8,
    "groupOnlyDate": "2/07/2020"
  }, {
    "groupDateArray": 2,
    "groupCurrentID": 5,
    "groupOnlyDate": "2/01/2020"
  }],
  "3": [{
    "groupDateArray": 3,
    "groupCurrentID": 7,
    "groupOnlyDate": "3/06/2020"
  }],
  "4": [{
    "groupDateArray": 4,
    "groupCurrentID": 41,
    "groupOnlyDate": "4/04/2020"
  }]
}
How to&Answer: