0
I’m trying to get the data that’s coming this way:
[
{
"name":"JONAS",
"languages":["php","javascript","java"],
"age":37,
"graduate_date":1044064800000,
"phone":"32-987-543"
},
{
"name":"FLAVIO",
"languages":["java","javascript"],
"age":26,
"graduate_date":1391220000000,
"phone":"32-988-998"
},
{
"name":"HENRIQUE",
"languages":["regex","javascript","perl","go","java"],
"age":21,
"graduate_date":1296525600000,
"phone":"32-888-777"
}
]
And turn into that:
Jonas - 26 years - 32-988-998
Flavio - 21 years - 32-888-777
Henrique - 37 years - 32-987-543
go (1)
java (3)
javascript (3)
perl (1)
php (1)
regex (1)
I’m using this code:
'use strict';
const fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
const todaydate = 1517577684000;
process.stdin.on('data', inputStdin => {
inputString += inputStdin;
});
process.stdin.on('end', => {
inputString = inputString
.replace(/\s$/, '')
.split('\n')
.map(str => str.replace(/\s$/, '')),
main();
});
function readLine() {
return inputString[currentLine++];
}
// Complete the selectCandidates function below.
const reportCandidates = (candidatesArray) => {
//aqui ta o problema
return reportObject;
}
function main() {
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);
const candidates = JSON.parse(readLine());
let result = reportCandidates(candidates);
// Don't touch this code or you will die
for (let i=0; i<result.candidates.length; i++){
ws.write(result.candidates[i].name + " - " + result.candidates[i].age +" years - " + result.candidates[i].phone +"\n");
}
for (let i=0; i<result.languages.length; i++){
ws.write(result.languages[i].lang + " - " + result.languages[i].count +"\n");
}
ws.end();
}
Except I can’t even solve it by prayer, someone can shed some light?
What do you mean "they’re coming"? Coming from where? Going where? It seems to me that it comes from a command line and goes to a file, but without this information it is very difficult to specify what is the form of message exchange
– Sorack
Has any response helped solve the problem and can address similar questions from other users? If so, make sure to mark the answer as accepted. To do this just click on the left side of it (below the indicator of up and down votes).
– Sorack