I have two array. 1) userDetails
, engToGerman
const userDetails= [
{
firstName: 'Michael Scott',
lastName: 'Dunder Mufflin',
designation: 'Regional Manager',
show: 'The Office',
responsibility: 'heart of the show'
},
{
firstName: 'Michael Scott',
lastName: 'Dunder Mufflin',
designation: 'Regional Manager',
show: 'The Office',
responsibility: 'heart of the show'
},
{
firstName: 'Michael Scott',
lastName: 'Mufflin',
designation: 'Regional Manager',
show: 'The Office',
responsibility: 'heart of the show'
},
]
engToGerman = [
firstName: 'name',
lastName: 'vorname'
]
Now I would like to modify user details like below where I translate the first name and last name from engToGerman and want to delete the rest of the information.
So the new user detail will look like this:
const newUserDetails= [
{
name: 'Michael Scott',
vorname: 'Dunder Mufflin',
},
{
name: 'Michael Scott',
vorname: 'Dunder Mufflin',
},
{
name: 'Michael Scott',
vorname: 'Mufflin',
}
]
How can I achieve this without modifying the original array?