Quantcast
Viewing all articles
Browse latest Browse all 8068

Populate a multidimensional array

Does anybody knows or give me some directions on how to populate a multidimensional data array:

I have one data array like this:

dataTable = ({section: 'section1', item: 'item1', num: 0},

{section: 'section2', item: 'item1', num: 0},

{section: 'section3', item: 'item1', num: 0}

{section: 'section3', item: 'item2', num: 0})

I need to populate that multidimension array like below:

tableToLoad = [{

sectionNum: 1,

sectionTitle: "section1",

data: [{

        level: 1,

        title: item1,

        child: false

    }]

},{

sectionNum: 2,

sectionTitle: "section2",

data: [{

        level: 1,

        title: item1,

        child: false

    }]

},{

sectionNum: 3, 

sectionTitle: "section3",

data: [{

        level: 1,

        title: item1,

        child: false

    }, {

        level:1,

        title: item2,

        child:false

    }]

}];

Thanks in advance...


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>