Answer to Question #171783 in HTML/JavaScript Web Application for hemanth

Question #171783

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


SampleInput 1

{'surname' : 'Williams', 'city': 'Columbia'}

{'dish': 'cakes'}

{'pet': 'Rocky'}


Sample Output 1

Mr and Mrs Williams went to a picnic in Columbia with a boy and a pet Rocky. Mrs Williams made a special dish "cakes"


Sample Input 2

{'surname' : 'Jones', 'city': 'Los Angeles'}

{'dish': 'puddings'}

{'pet': 'Peter'}

Sample Output 2

Mr and Mrs Jones went to a picnic in Los Angeles with a boy and a pet Peter. Mrs Jones made a special dish "puddings"






1
Expert's answer
2021-03-15T12:15:01-0400
function uniteFamily(father, mother, child) {
    return `Mr and Mrs ${father['surname']} went to a picnic in ${father['city']} with a boy and a pet ${child['pet']}. Mrs ${father['surname']} made a special dish "${mother['dish']}"`
}

const res = uniteFamily({'surname' : 'Jones', 'city': 'Los Angeles'}, {'dish': 'puddings'}, {'pet': 'Peter'});

console.log(res);

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