Answer to Question #171394 in HTML/JavaScript Web Application for mani

Question #171394

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


Sample Input

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

{'dish': 'puddings'}

{'pet': 'Peter'}


Sample Output

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-13T12:04:13-0500
"use strict";

process.stdin.resume();
process.stdin.setEncoding("utf-8");


let inputString = "";
let currentLine = 0;


process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});

process.stdin.on("end", (_) => {
    inputString = inputString.trim().split("\n").map((str) => str.trim());
    main();
});

function readLine() {
    return inputString[currentLine++];
}

/* Please do not modify anything above this line */

function main() {
    const father = JSON.parse(readLine().replace(/'/g, '"'));
    const mother = JSON.parse(readLine().replace(/'/g, '"'));
    const child = JSON.parse(readLine().replace(/'/g, '"'));

    const family = {
        surname: 'Jones',
        city: 'Los Angeles',
        pet: 'Peter',
        dish: 'puddings'
    }

    /* Please do not modify anything below this line */
    console.log(`Mr and Mrs ${family.surname} went to a picnic in ${family.city} with a boy and a pet ${family.pet}. Mrs ${family.surname} made aspecial dish "${family.dish}"`);
}

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

Assignment Expert
31.05.21, 12:41

Dear lekha, if you have serious assignment that requires large amount 

of work and hence cannot be done for free you can submit it as assignment and our 

experts will surely assist you.




lekha
31.05.21, 04:11

how to take input from users

chandu
02.04.21, 09:58

in this same program how can we take the inputs from user?

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS