Typeerror : Inventory update challenge

function updateInventory(arr1, arr2) {
// All inventory must be accounted for or you’re fired!
var inventory = arr1.concat(arr2);
var temp;
var temp1, temp2;
var answer = [];
//sort inventory
function comparator(a,b)
{
if(a[1]<b[1]) return -1;
if(a[1]>b[1]) return 1;
return 0;
}

inventory = inventory.sort(comparator);
for( i = 0 ; i < inventory.length ; i++)
{
if(inventory[i][1]==inventory[i+1][1])
{
answer.push([inventory[i][0]+inventory[i+1][0],inventory[i][1]]);
inventory.splice(inventory[i+1], 1);
}
return answer;
}

}