This is complicated to explain in words so let me just show you what I've got and work from there.
I have the following object:
{
1: { name: 'Initial Step 1', stepNumber: 1 },
2: { name: 'Initial Step 2', stepNumber: 2 },
3: { name: 'Initial Step 3', stepNumber: 3 },
4: { name: 'Initial Step 4', stepNumber: 4 },
}
I would like to perform a delete function for this step and then decreme the trailing keys so that I get the following outcome:
{
1: { name: 'Initial Step 1', stepNumber: 1 },
2: { name: 'Initial Step 3', stepNumber: 2 },
3: { name: 'Initial Step 4', stepNumber: 3 },
};
I'm just not sure of the best way to implement my deleteStep
function.
I've got it implemented as follows:
export const deleteStep = (stepNumber, steps) => {
// What should I do here?
return steps;
};
Thanks!