Super Excited for completing this challenge: Inventory Update :)

Super Excited for completing this challenge: Inventory Update :)
0.0 0

#1

function updateInventory(arr1, arr2) {
    // All inventory must be accounted for or you're fired!

    for(var i = 0; i < arr2.length; i++){
      for(var j = 0; j < arr1.length; j++){
        if(arr2[i] === undefined){
          break;
        }
        if(arr2[i][1] == arr1[j][1]){
          arr1[j][0] += arr2[i][0];
          arr2.splice(i,1);
        }
      }
    }
    return arr1.concat(arr2).sort(function(a, b){
      return a[1] > b[1];
    });
}

// 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);

#2

Virtual high five!!!


#3

virtual high five to you too… lol :raised_hand::+1:


#4

yeah, that was not an easy challenge. The next one however is maybe the hardest of all the algorithm challenges. Fight on!