Hi can’t seem to figure out why the below else statement would cause an infinite loop, my logic was that if the item in arr2 is not equal to any of the items in arr1, the item itself would be pushed onto arr1 in the else statement, I have tried to put a variable counter3 in there consolelog how many times it matches the else statement, it matches 14x for some reason, where I was expect 2 as arr1 is missing 2 items from arr2. Thank you for your help
function updateInventory(arr1, arr2) {
// All inventory must be accounted for or you're fired!
var counter1;
var counter2;
var counter3=0;
for ( counter1=0; counter1<arr1.length; counter1++){
for (counter2=0; counter2<arr2.length; counter2++) {
if ( arr2[counter2][1] == arr1[counter1][1]) {
arr1[counter1][0]=arr1[counter1][0]+arr2[counter2][0];
//counter3++;
//console.log(counter3);
}
else {
counter3++;
console.log(counter3);
arr1.push(arr2[counter2]); //this part causing the infinite loop warning
}
}
```