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



Expert's answer

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!

LATEST TUTORIALS
APPROVED BY CLIENTS