Consider the following array:
array = [[3, 3], [3, 4], [3, 5], [3, 6]]
Now let's take a look at this conditional statement:
array = [[3, 3], [3, 4], [3, 5], [3, 6]]
for(let i = 0; i < array.length; i++){
if (array[i][0] === 3 && array[i][1] === 4 || array[i][0] === 3 && array[i][1] === 5){
console.log(i)
}
}
In this scenario, the indexes that would be printed are 1
and 2
, showing up sequentially in the console.log()
.
Your challenge is to extract the minimum index (1
in this case) from within the loop. It isn't possible to store these numbers in an array due to certain constraints, so the minimum must be determined during iteration without prior knowledge of which element will have the smallest index.
Do you think this task can be accomplished or is it a case of overthinking the problem?