Let's say I have an array of emails:
['[email protected]', '[email protected]', '[email protected]']
I need to convert it into an array of objects that looks like this:
[
{
id: '[email protected]',
invite_type: 'EMAIL'
},
{
id: '[email protected]',
invite_type: 'EMAIL'
},
{
id: '[email protected]',
invite_type: 'EMAIL'
}
]
In order to do that, I have written the following code:
$scope.invites = [];
$.each($scope.members, function (index, value) {
let inviteMember = {
'id': value,
invite_type: 'EMAIL'
}
$scope.invites.push(inviteMember);
});
Is there any better way of doing this?