I possess an array
containing JSON
data named config
.
var config = [ [{'state': 'step1'}],
[{'state': 'step2'}] ,
[{'state': 'step3'}]
];
The data in config
is orderly arranged.
Additionally, I hold JSON
data named Events
, which includes these states but they are not sequential. I aim to modify the Events
data based on the config
.
Events: [
{ Status: 'rendered', State: 'step2' },
{ Status: 'rendered', State: 'step3' },
{ Status: 'rendered', State: 'step1' } ,
{ Status: 'completed', State: 'step3'}
],
Moreover, the final step of the config will have two entries and in that case, the rendered state should precede the completed state.
The expected outcome is as follows:
Events: [
{ Status: 'rendered', State: 'step1' },
{ Status: 'rendered', State: 'step2' },
{ Status: 'rendered', State: 'step3' } ,
{ Status: 'completed', State: 'step3' }
]
Note: I do not currently have any functional or error-prone code for this task. Essentially, I am struggling to figure out how to utilize the config
to modify the Events
.
Thank you