I have:
var array1 = [];
var array2 = [];
array1
contains 1
,2
array2
contains 3
,4
And I want to do this:
for(var a in array1){
for(var b in array2){
doSomething(array1[a],array2[b]);
}
}
But the problem is that function doSomething()
runs twice for each array because of the two for
's.
How should run it just once but with all of the arrays?
EDIT
The numbers are not in ascending order! In my real project they are ID
's what can be any number in any order.