Tell us what’s happening:
Hi guys, pretty sure I got the answer right, but they’re not letting me complete the lesson for some reason?
Your code so far
function updateInventory(curInv, newInv) {
let entireInv = curInv;
newInv.map(item => {
for (let i = 0; i < entireInv.length; i++) {
if (item[1] === entireInv[i][1]) {
entireInv[i][0] = entireInv[i][0] + item[0];
return undefined;
}
}
entireInv.push(item);
});
entireInv.sort((a, b) => a[1] > b[1]);
return entireInv;
}
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);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
.
Link to the challenge: