I have an array of objects like this:
const customers = [
{
customer_name: 'Negan',
customer_age: 45,
customer_weapon: 'Bat',
customer_email: '[email protected]',
customer_city: 'Washington'
},
{
customer_name: 'Daryl',
customer_age: 41,
customer_weapon: 'Crossbow',
customer_email: '[email protected]',
customer_city: 'Atlanta'
},
{
customer_name: 'Rick',
customer_age: 45,
customer_weapon: 'Magnum 357',
customer_email: '[email protected]',
customer_city: 'King County'
},
]
and I want to replace all keys inside objects with these keys:
const newKeys = [
'firstname',
'age',
'weapon',
'email',
'city'
]
What is the best way to do this? An example will be appreciated!