1π
β
To display the right format you probably want to map over selectedWorkers
to select the keys you want (id and name), using string template syntax. Then use join
to combine the result
alert(this.selectedWorkers.map(worker=>`${worker.id}-${worker.name}`).join())
Example of assumed format:
const selectedWorkers = [{
id: 'AA',
name: 'Lou Poole'
},{
id: 'BB',
name: 'Jonathan Fuller'
}]
alert(selectedWorkers.map(worker => `${worker.id}-${worker.name}`).join())
π€depperm
Source:stackexchange.com