Writing code in C/C++ way when we had to iterate an array we wrote
for(int index = 0; index < array.size(); index++) {
doSomething(index);
}
when it was necessary to iterate by 4 we wrote
for(int index = 0; index < array.size(); index = index + 4) {
doSomething(1, index);
doSomething(2, index+1);
doSomething(3, index+2);
doSomething(4, index+3);
}
How can I achieve this by using JavaScript's map reduce or filter array functions?