I have a set of objects that I want to convert into objects with specific key names, following the format {key}{index)
const input = [
{
item: 'Apple',
amount: '3'
},
{
item: 'Banana',
amount: '5'
},
// ...
]
Here is an illustration of the expected output where each index gets added to the key name resulting in item1, amount1, item2, amount2..
const output = { item1: 'Apple', amount1: 3, item2: 'Banana', amount2: 5 }