I'm studying React and json objects, but I can't obtain what i want:
Here is the code:
const selectOptions1 = {
9: 'good',
14: 'Bad',
26: 'unknown'
};
const selectOptions2 = options.map((item) => {
return (
{ [item.value]:item.label }
)
})
console.log(selectOptions1) // {9:good, 14:bad, 26:unknown}
console.log(selectOptions2) // [{…}, {…}, {…}] -> 0: {9: "good"} 1: {14: "bad"} 2: {26: "unknown"}
How can I create an object like selectOptions1 using map (instead of the structure like in selectOptions2)?
optionshere?