Hi, I have been trying some coding challenges at hackerrank and I keep getting an error message when trying to run the code. The funny thing is that the error message has to do with something which was already prewritten in hackerank. I appreciate any help I can get.
I will paste the code and the error message.
'use strict';
const fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
inputString += inputStdin;
});
process.stdin.on('end', function() {
inputString = inputString.replace(/\s*$/, '')
.split('\n')
.map(str => str.replace(/\s*$/, ''));
main();
});
function readLine() {
return inputString[currentLine++];
}
// Complete the breakingRecords function below.
function breakingRecords(scores) {
let Min=scores[0];
let Max=scores[0];
let minRecord=0;
let maxRecord=0;
let i;
for (i=1; i<scores.length; i++){
if (scores[i]<Min) {
Min=scores[i];
minRecord+=1;
}
else if (scores[i]>Max) {
Max=scores[i]
maxRecord+=1;
}
console.log(maxRecord+" "+minRecord);
}
}
function main() {
const ws = fs.createWriteStream(process.env.OUTPUT_PATH);
const n = parseInt(readLine(), 10);
const scores = readLine().split(' ').map(scoresTemp => parseInt(scoresTemp, 10));
const result = breakingRecords(scores);
ws.write(result.join(' ') + '\n');
ws.end();
}
Error message