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
Get step-by-step solutions from verified subject matter experts
