"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++];
}
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 */
}
input1
{ 'name':'Pranay', 'address':{'city':'Mumbai','state':'maharastra'}, 'nicknames':['nani','chanti']}
output2
pranay is from mumbai,maharastra
pranay has 2 nicknames
length is not defined but output is come
"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++];
}
function main() {
/*input1
{'name':'Pranay', 'address':{'city':'Mumbai','state':'maharastra'}, 'nicknames':['nani','chanti']}*/
let person = JSON.parse(readLine().replace(/'/g, '"'));
/* Please do not modify anything above this line */
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