I have this structure:
materials= ["a","b","c"]
and I need it to be like this:
data= [{material:"a"},{material:"b"},{material:"c"}]
You can use map:
materials.map(a=> ({material: a}))
An example:
let materials= ["a","b","c"];
const result = materials.map(a=> ({material: a}))
console.log(result)
or even shorter (thanks to Ele):
materials.map(material => ({material}));
let materials= ["a","b","c"];
const result = materials.map(material => ({material}));
console.log(result)
materials.map(material => ({material}))