how can I form a multi-level array in Jquery. Here's what I have, but I'm sure im in the wrong way
newTutorial[0]['header'] = 'some header';
newTutorial[0]['text'] = 'some text';
newTutorial[1]['header'] = 'some header';
newTutorial[1]['text'] = 'some text';
...
and I need such thing for more than 17 elements
If I have understood your question correctly, then you can do something like following
var times = 17; // you can define times over here
for (var i = 0 ; i < times; i++) {
newTutorial[i]['header'] = 'some header';
newTutorial[i]['text'] = 'some text';
}
Or just with do-while
loop
var i=0;
do {
newTutorial[i]['header'] = 'some header';
newTutorial[i]['text'] = 'some text';
i++;
}
while (i < 17);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With