0

I have the following object:

animalDescription = 
{
  "tiger":{
     type:"tiger", 
     food: [...]
   },
  "buffalo":{ 
     type:"buffalo,
     food:[...]
  }
}

I want to remove the keys and transform it to this:

[{type:"tiger", food:[...]}, {type:"buffalo", food:[...]}]

I'm currently doing the following:

const animals = [];

for (const key in animalDescription) {
  animals.push(animalDescription[key]);
}
   return animals;
}

Is there a cleaner way to deconstruct this?

lost9123193
  • 9,040
  • 22
  • 62
  • 100

0 Answers0