1
My job:
nameById (url, list, getter = "name") {
let name = '';
let id = url.split('/').reverse()[1];
list.map( user => user.id == id ? name = user.name : null); // name = user.getter
return name;
},
Is there any way to use this getter parameter inside the map ? That way I could use this function not only to search for "name" but for any other key.
nameById('http://localhost:8000/scrum-list/sprint-list/7/', sprintList, 'code') // O retorno seria a propriedade de code e não name
Try it this way
list.map( user => user.id == id ? name = user[getter] : null);
– BrTkCa
It worked, vlw!!! I didn’t know it was possible to do this.
– user90136