I Have json data and i want to manipulate it and store in state setNewdata
const [newdata, setNewdata] = useState([])
const data = [{
id: 2048,
title: 'フューチャーワークス',
account_title_id: 1,
detailed_id: 1,
currency_id: 2,
},
{
id: 2056,
title: 'ああああああ',
account_title_id: 1,
detailed_id: 2,
currency_id: 2,
},
]
i want to mainpulate this json to add two key there is label and value in react
[{
id: 2048,
title: 'フューチャーワークス',
account_title_id: 1,
detailed_id: 1,
currency_id: 2,
label: 'フューチャーワークス - 2048', // combine from id and title
value: '1 - 1 - 2', // combine from account_title_id,detailed_id
},
{
id: 2056,
title: 'ああああああ',
account_title_id: 1,
detailed_id: 2,
currency_id: 2,
label: 'ああああああ - 2048', // combine from id and title
value: '1 - 2 - 2', // combine from account_title_id,detailed_id,currency_id
},
]
data.forEach((current) => {
,....
})