I'm having trouble manipulating arrays of different types, specifically when working with interfaces. It's a simple issue, but I could use some help.
Here are the two interfaces I'm using:
export interface Group {
gId: number;
gName: string;
}
export interface UserGroup {
uId: number;
gId: number;
}
I currently have two arrays:
finalUserGroupsToUpdate: UserGroup[];
pickListUserAssociatedGroups: Group[];
The Group array is already filled and looks like this in the console:
(3) [{...}, {...}, {...}]
0: {gId: 1, gName: "Manager"}
1: {gId: 2, gName: "Nurse"}
2: {gId: 3, gName: "Audit"}
I also have access to uId through the active route in Angular (for this example, it can be treated as a local variable):
currentUserID = 1;
My goal is to push each gId from the Group array into the UserGroup array while adding currentUserID as the uId.
The desired final outcome should resemble:
(3) [{...}, {...}, {...}]
0: {gId: 1, uId: 1}
1: {gId: 2, uId: 1}
2: {gId: 3, uId: 1}