I need to loop through an array using the for clause, but starting at some specific index and just to a maximum of iterations.
The code below does the task, but it looks awful to me: it’s there a better way?
var offset = 10, max = 5;
for (var i = 0; (i + offset) < data.length && i < max; i++) {
doSomething(data[i + offset]);
}
If I am understanding your question correctly you would just need to initialize i to the offset.
edit: didn’t understand the max at first.