My Object nested array is following way,
const values: any = {
name: '',
type: undefined,
references: [
{
origin: {
x1: true,
x2: '',
x3: undefined,
},
},
{
origin: {
x1: true,
x2: '',
x3: undefined,
},
},
{
origin: {
x1: true,
x2: '',
x3: undefined,
},
},
],
};
I want to update x3 field with references array index, How can I achieve this by using ES6 arrow function. I wrote a function but It doesn't work for me. It would be great if someone can correct my function,
export const replaceReferenceIndex = (values: any) => {
return {
...values,
references: values.references.map((reference.origin: any, x3: number) => ({
...reference.origin,
x3,
})),
};
};