Below object should be converted into an array of object. This is just a random problem statement. How to convert this to an array of objects? Please help.
// input
objects={
0:[1,2,3],
1:["a","b","c"],
2:["i","ii","iii"]
}
//expected output
objects2=[
{0:1,1:"a",2:"i"},
{0:2,1:"b",2:"ii"},
{0:3,1:"c",2:"iii"}
]
Below code gives me only last entry mean
[3,"c","iii"]
//tried solution
var res=[]
Object.keys(objects).forEach(k=>{
// console.log(data[k])
objects[k].forEach(element => {
res[k]=element
console.log(res)
});
})