Trying to articulate my thoughts, I am interested in linking a list of skill sets to various individuals within their respective lists.
For instance: I possess a Json object detailing individuals:
"people": [
{
"id": 1,
"name": "Tony Rogers",
},
{
"id": 2,
"name": "Steven Grant",
},
{
"id": 3,
"name": "Peter Wilson",
},
]
Additionally, there exists a roster of skills that need to be associated with them:
"skills": [
{
"id": 1,
"name": "Engineering",
"personId": 1
},
{
"id": 2,
"name": "Painting",
"personId": 2
},
{
"id": 3,
"name": "Chemistry",
"personId": 3
},
{
"id": 4,
"name": "Physics",
"personId": 1
},
]
Navigating through both lists remains a bit uncertain for me. Ideally, I aim to attach a "skills" segment to each individual containing all of their relevant skills.
I toyed with the idea of:
people.forEach(function(person){
skills.forEach(function(skill){
if(skill.personId == person.id){
person['skills'] = {"name" : skill.name};
}
});
});
However, this approach results in repetitive entries for an individual rather than consolidating their skills.