I have an ajax call which returns same data
obj[0],obj[1],obj[2],obj[3],obj[4],obj[5],obj[6],obj[7],obj[8],obj[9],obj[10],obj[11]....
So i want to take only obj[0]-obj[3] and obj[4]-obj[7] and obj[8]-obj[11]...
var iterate=0;
for(i=0 ;i<obj.length ; i++)
{
alert(obj[iterate].mydata);
iterate=iterate+3;
}
here the issue is , it iterates each time so i cant get valjue of obj[4] after obj[3] Any idea ?
objsupposed to be an array or what? Are you trying to split an array into chunks? I don't see what the difference would be betweenobj[0]-obj[3] and obj[4]-obj[7]and justobj[0]-obj[7]. Please provide a concrete example of the input and output you (want to) get. The better you describe your problem, the easier it is for us to help you.I want to take only ...only what? obj[0] minus obj[3]? Or the sum of obj[0] to obj[3]? You're talking in rebuses. You may also want to slice the original array into smaller arrays, etc. The point is, you have to explain your problem and expected solution in a way so we understand it.