Here are the configurations I am working with:
type Choice = {
value: any,
label: any
}
Additionally, there is a role interface:
export interface UserRole {
id: number
name: string
}
I have a set of roles:
const userRoles:UserRole[]:[
{id:1,name:'name1'},
{id:2,name:'name2'},
{id:3,name:'name3'}
]
My goal is to extract Choices[] from this set of roles. How can I achieve this in javascript?
In java, I could use the following code snippet:
roles.stream().map(role->new Choice(role.id,role.name)).collect(collectors.toList());