I have to find an object from an array of objects if the object is found then I have to add sort property to it, if it is not found then I am looking for another object. but if all the objects are present then I have to add sort property to first match only. I am using the switch case to achieve this. but if all the objects are present the sort property is added to all the objects. could anyone please tell me how can I achieve this?
Below is my code.
this.columns = this.columns.map(field) => {
delete field.id;
switch (field.name) {
case 'creationTime':
field.sort = 'asc';
break;
case 'priority':
field.sort = 'asc';
break;
case 'completionTime':
field.sort = 'asc';
break;
}
return field;
});