# Typeerror : Inventory update challenge

**URL:** <https://forum.freecodecamp.org/t/typeerror-inventory-update-challenge/92617>\
**Category:** General\
**Created:** [March 2, 2017, 3:03am UTC](https://forum.freecodecamp.org/t/typeerror-inventory-update-challenge/92617 "2017-03-02T03:03:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![irfanharunk](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/irfanharunk/32/24907_2.png) [@irfanharunk](https://forum.freecodecamp.org/u/irfanharunk)\
**Post date:** [March 2, 2017, 3:03am UTC](https://forum.freecodecamp.org/t/typeerror-inventory-update-challenge/92617/1 "2017-03-02T03:03:08Z")

</div>

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;  
}

}

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:49pm UTC](https://forum.freecodecamp.org/t/typeerror-inventory-update-challenge/92617/2 "2021-01-17T20:49:49Z")

</div>

Closed on January 17, 2021, 8:49pm UTC


