Код:
https://jsfiddle.net/tquL6oax/1/let arr = [ 10, 30, 40, 100, 70, 1000, 2000, 80, 90, 180, 85, 75, 65, 200 ];
const fn = ( arr ) => {
let high = 0;
let next = 0;
for( let i = 0; i < arr.length; ++i ) {
if( arr[ i ] > high ) {
next = high;
high = arr[ i ];
}
else if( arr[ i ] > next ) {
next = arr[ i ];
}
else {
continue;
}
}
return [ high, next ];
}
console.log( fn( arr ));