function findSecondMax(arr) {
let max = arr[0];
let second = 0;
for (let i = 1; i < arr.length; i++) {
const item = arr[i];
if (item > max) {
second = max;
max = item;
}
if (item > second && item < max) {
second = item;
}
}
return second;
}
// 9
findSecondMax([1, 2, 4, 10, 1, 6, 8, 7, 4, 2, 3, 9]);