Question: Javascript ES6 Write a function called adjustName. The adjustName function accepts an object as an argument. This function will remove the key 'name' and add

Javascript ES6

Javascript ES6 Write a function called adjustName. The adjustName function accepts an

Write a function called adjustName. The adjustName function accepts an object as an argument. This function will remove the key 'name' and add two new keys 'firstName' and 'lastName' and return the object. It will set the values of 'firstName' and 'lastName' correctly based on the values in the 'name' array. You may assume that the first item in the 'name' array is the first name and that the last item is the last name. Consider some people have multiple middle names so the last item in the array MUST be accessed dynamically. NO For..In iteration is needed. Please do not use. const dc = { name: ['Bruce', 'Wayne'], hero: 'Batman' const marvel = { name: ['Peter', 'Benjamin', 'Parker'l, hero: 'SpiderMan' }; adjustName (dc); EXPECTED OUTPUT (object): { hero: 'Batman', firstName: 'Bruce', lastName: 'Wayne' } adjustName (marvel); EXPECTED OUTPUT (object): { hero: 'SpiderMan', firstName: 'Peter', lastName: 'Parker' }

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!