Hey Guys
I tried to work on this challenge but it seems that doesn’t work
what’s wrong with my code?
function updateInventory(arr1, arr2) {
// All inventory must be accounted for or you're fired!
for (var i = 0; i < arr1.length; i++) {
for (var j = 0; j < arr1[i].length; j++) {
for (var k = 0; k < arr2.length; k++) {
arr1.forEach(function(item) {
if (arr1.indexOf(arr1[i][j]) > 0 && arr2[k].indexOf(item) > 0) {
arr2[k][item].push(arr1[i][j]);
return arr1;
}
});
}
}
}
return arr1;
}
// Example inventory lists
var curInv = [
[21, "Bowling Ball"],
[2, "Dirty Sock"],
[1, "Hair Pin"],
[5, "Microphone"]
];
var newInv = [
[2, "Hair Pin"],
[3, "Half-Eaten Apple"],
[67, "Bowling Ball"],
[7, "Toothpaste"]
];
updateInventory(curInv, newInv);