Person Details
given an object person containing a person details, write a JS program to log the name, address and nicknames count.
input1
output2
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 */
}
"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`);
}
Comments
Leave a comment