0

What is the best way to loop through the below object?

object {
   ATR: [object {
     company:'Apple',
     funded: 'Yes',
     funding: 'Expected',
     program: 'ATR'
   },object {
     company:'Google',
     funded: 'Yes',
     funding: 'Expected',
     program: 'ATR'
   }],
   QTR: [object {
     company:'Apple',
     funded: 'Yes',
     funding: 'Expected',
     program: 'QTR'
   }],
   RES:[],
   STR: [object {
     company:'Apple',
     funded: 'Yes',
     funding: 'Expected',
     program: 'STR'
   },object {
     company:'Google',
     funded: 'Yes',
     funding: 'Expected',
     program: 'STR'
   }]
}

I tried the following code but it just returned an empty array. My goal is to be able to loop through the data and show a table grouped by 'program' property.


function loopThrough(data){
  for (key in data){
    console.log(data[key])
  }
}

Here's the pen

Any help would be much appreciated.

Thanks!

OLA
  • 861
  • 2
  • 11
  • 23

0 Answers0