I have multiple if statements (50/60) inside a loop.What would be the best approach to perform this actions, switch or map lookup? How can i implement map lockups for the following examples?
errors.forEach((e) => {
if (e.field === 'firstName') {
this.hasErrorFirstName = true;
this.msgFirstName = e.error;
}
if (e.field === 'lastName') {
this.hasErrorLastName = true;
this.msgLastName = e.error;
}
if (e.field === 'middleName') {
this.hasErrorMiddleName = true;
this.msgMiddleName = e.error;
}
if (e.field === 'address') {
this.hasErrorAddress = true;
this.msgAddress = e.error;
}
}