Question: (Javascript) Write a function called combineName that takes an object, array of keys to combine and a destination key. It returns an object with the

(Javascript) Write a function called combineName that takes an object, array of keys to combine and a destination key. It returns an object with the correct keys combined.

const person = { first: 'Elon', last: 'Musk', twitter: '@elonmusk', company: 'Space X' } combineName(person, ['first', 'last'], 'name') // Notice the object also no longer contains the keys first or last // and they have been combined into the new key called name { twitter: '@elonmusk', company: 'Space X', name: 'Elon Musk' } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!