function secondLargest(arr) {
if (arr.length < 2) return null; // Handle edge case for arrays with less than 2 elements
let first = -Infinity, second = -Infinity;
for (let num of arr) {
if (num > first) {
second = first;
first = num;
} else if (num > second && num < first) {
second = num;
}
}
return second;
}
let numbers = [3, 14, 14, 1, 1, 1, 90, 2, 6, 86, 7];
console.log(secondLargest(numbers));
/*
run:
86
*/