I'm having trouble formatting my array for localStorage storage. Is it possible to change the index value of an array? Here's what my array object looks like:
const myArray = [{id: 41, name: "x"}, {id: 42, name: "y"}]
But I would like it to be structured like this:
const myArray = [ 41: {id:41, name:"x" }, 42: {id:41, name:"y" }}
This way, the id of the object becomes the index of the array
If that's not achievable, then this alternative format would also work:
const myArray = [ {41: {id:41, name:"x"} }, {42: {id:41, name:"y"}}]
In essence, I want the id of the object to serve as either the index or a container object for that particular object.