JSFiddle - React, Tailwind, and code Playground
by Sebastian
JavaScript
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"]
];
var InvObj = [];
var curObj;
function makeObj (item, index, array) {
curObj = {};
curObj[item[1]] = item[0];
InvObj.push(curObj);
}
curInv.forEach(makeObj);
console.log(InvObj[1]['Dirty Sock']);