I have the following script. As you can see item.value
and item.name
are differently. Can I write this more dynamically, easily in javascript?
setOptions(id, selection) {
var options = ''
var newArray = []
if (selection == 'settings') {
options = this.getStatuses(id);
newArray = options.map(item => { return { id: item.id, text: item.value } });
} else if (selection == 'route' && id == 'profiles') {
options = this.getProfiles;
newArray = options.map(item => { return { id: item.id, text: item.name } });
}
return newArray
}