I have an array with objects:
const teams = [{
TeamId: "asfqef",
Projects: [{
ProjectId: "wfwef",
TeamId: "asfqef"
}]
}];
projectCreated ={ProjectId: "aaaa", TeamId: "asfqef"};
so I need to push a Project into a especific Team, so for that I make It:
this.teams.forEach(team => {
if (team.TeamId = projectCreated.TeamId ){
team.Projects.push(projectCreated);
}
});
My problem is that it is inserting the Project into all the Teams, so what's wrong with my logic?