Inventory Update

The activity was challenging and I hope I will get full understanding about it and have a better understanding.

Problem

Compare and update the inventory stored in a 2D array against a second 2D array of a fresh delivery. Update the current existing inventory item quantities (in arr1). If an item cannot be found, add the new item and quantity into the inventory array. The returned inventory array should be in alphabetical order by item.

Approach

Had a first for-loop which will iterate through each item in the second array, checks does the current item match any existing items? If so, update their quantity. Make foundMatch true so it doesnt add the item later, outside of this iteration, therefore it checks if the second for-loop did iterating through the array turn up a match?, if not so create new item then we sort everything that is in the array.

Conclusion

The activity I was solving it wasnt an easy activity and I hope I will have a better understanding by doing it many times as possible because it was very hard.