Answer to Question #175882 in HTML/JavaScript Web Application for mahidhar

Question #175882

Unite Family

Given three objects

father, mother, and child, write a JS program to concatenate all the objects into the family object using the spread operator.Input

  • The first line of input contains an object father
  • The second line of input contains an object mother
  • The third line of input contains an object child

Output

  • The output should be a single line string with the appropriate statement as shown in sample outputs

Constraints

  • Keys of the objects should be given in quotes
1
Expert's answer
2021-03-26T19:18:31-0400
function uniteFamily( obj ) {
    for ( key in obj ) {
        console.log(key + ': ' + obj[key]);
    }
}

let father = {
    name: 'father',
    age: 36
}

let mother = {
    test: 'test'
}

let child = {
    hobby: 'basketboll'
}

uniteFamily( {...father, ...mother, ...child} )

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS