const arr = [-1, -2, -3, 4, 5, 7, 8, 4];
let second =-Infinity
let max=-Infinity
let result = [];
for( let num of arr){
if(num>max){
second=max
max=num
}
else if(num>second && num<num){
second=num
}
}
console.log(second)
console.log(max)