help to solve in this javascript problem. Give me clear documentation about (join).
JavaScript
x
13
13
1
function main() {
2
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);
3
4
const a = readLine().replace(/s+$/g, '').split(' ').map(aTemp => parseInt(aTemp, 10));
5
6
const b = readLine().replace(/s+$/g, '').split(' ').map(bTemp => parseInt(bTemp, 10));
7
8
const result = compareTriplets(a, b);
9
10
ws.write = (result.join(',') + 'n');
11
12
ws.end();
13
}
Advertisement
Answer
Clear documentation for join
JavaScript
1
2
1
const result = compareTriplets(a, b);
2
Not sure what compareTriplets is but based on the word compare I am assuming it returns a boolean. You are trying to join a boolean expression. If you want one string containing of A and B then put A and B into an array and then use join. But with so little information it is hard to understand what you are trying to accomplish.
Based on your code I am assuming A and B both are arrays. If you want to join the elements together do this. Also assuming result is a boolean.
JavaScript
1
15
15
1
function main() {
2
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);
3
4
const a = readLine().replace(/s+$/g, '').split(' ').map(aTemp => parseInt(aTemp, 10));
5
6
const b = readLine().replace(/s+$/g, '').split(' ').map(bTemp => parseInt(bTemp, 10));
7
8
const result = compareTriplets(a, b);
9
10
if(result){
11
ws.write = (a.join(',') + ',' + b.join(',') + 'n');
12
}
13
ws.end();
14
}
15