Answer to Question #310338 in HTML/JavaScript Web Application for vicky

Question #310338

Person Details

given an object person containing a person details, write a JS program to log the name, address and nicknames count.

input1

  • the input will be a single containig an object person

output2

  • the first line of output should contain the name and address of the person as shown in the sample output
  • the second line of output should contain nicknames count as shown in sample output.

input1

{ 'name':'Pranay', 'address':{'city':'Mumbai','state':'maharastra'}, 'nicknames':['nani','chanti']}

output2

pranay is from mumbai,maharastra

pranay has 2 nicknames


"use strict";

process.stdin.resume();

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

let inputString = "";

//////

/////

/////

function main() {

 let person = JSON.parse(readLine().replace(/'/g, '"'));


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


 /* Write your code here and log the output */

}



1
Expert's answer
2022-03-14T17:09:25-0400
"use strict";

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = "";
//////
/////
/////
function main() {
    let person = JSON.parse(readLine().replace(/'/g, '"'));
    /* Please do not modify anything above this line */
    /* Write your code here and log the output */
    console.log(`${person.name} is from ${person.address.city}, ${person.address.state}`);
    console.log(`${person.name} has ${person.nicknames.length} nicknames`);
}

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