so I have an array in which I store values in pairs. I can't use an object because keys may repeat so I use an array instead.
This is how the array may look:
array = ['id1', 'id5', 'id9', 'id12', 'id2', 'id9', 'id1', 'id4'];
So I want to iterate through it and get all the pairs, so I can use them for another function:
var a = 'id1';
var b = 'id5';
doStuffWithThePair(a, b);
var a = 'id9';
var b = 'id12';
doStuffWithThePair(a, b);
var a = 'id2';
var b = 'id9';
doStuffWithThePair(a, b);
var a = 'id1';
var b = 'id4';
doStuffWithThePair(a, b);
I tried with for loops, using if(i%2 == 0) but it doesn't work. How can I make this? Thanks in advance!
for (var i = 0; i < array.length - 1; i=i+2) { doStuffWithThePair(array[i], array[i+1]) }?