Tengo el siguiente objeto:
{ "thumbnail": { "height": 150, "width": 150, }, "medium": { "height": 165, "width": 300, }, "large": { "height": 352, "width": 640, } }Quiero crear la siguiente matriz a partir del objeto.
[ { "slug": "thumbnail", "name": "Thumbnail" }, { "slug": "medium", "name": "Medium" }, { "slug": "large", "name": "Large" }, { "slug": "full", "name": "Full" } ]¿Cómo puedo obtener el nombre de la clave del objeto para agregarlo a la matriz? Intenté lo siguiente:
map( imageSizesArray, ( { key } ) => ( { value: key, label: key.toUpperCase() } ) );Pero no funciona
const obj = { "thumbnail": { "height": 150, "width": 150, }, "medium": { "height": 165, "width": 300, }, "large": { "height": 352, "width": 640, } } const retrnArr = Object.keys(obj).map(e =>{ return { 'value': e , 'label' : e.toUpperCase()} }); console.log(retrnArr)