Answer to Question #175997 in HTML/JavaScript Web Application for bhadra

Question #175997

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

how it is possible two outputs(sample output 1, sample output 2) in this program



1
Expert's answer
2021-03-27T17:31:36-0400
function uniteFamily( obj ) {
    for ( key in obj ) {
        console.log(key + ': ' + obj[key]);
    }
}

let father = {
    name: 'Bob',
    age: 52
}

let mother = {
    city: 'London'
}

let child = {
    hobby: 'footbal'
}

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