Hi i dont understand why my code isn’t workin i tested on the terminal of node.js and it work but now in codingame didn’t, any one can tell me why? thanks before hand.
const n = parseInt(readline()); // the number of temperatures to analyse
let numbers = readline().split(' ');
let pos = [];
let neg = [];
let num;
if(n > 0){
for(i in numbers)
{
const t = parseInt(numbers[i])
if(numbers[i]<0){
neg.push(numbers[i]);
}
else if(numbers[i]>0){
pos.push(numbers[i]);
}
pos.sort(function(a,b){return a-b});
neg.sort(function(a,b){return b-a});
}
if(pos[0]===Math.abs(neg[0])) {
console.log(pos[0])
}else if(pos[0]<Math.abs(neg[0])){
console.log(pos[0]);
}else if (pos[0]>Math.abs(neg[0]) ||pos[0]===undefined){
console.log(neg[0]);
}
}
else{
console.log(0);
}