у меня так получилось
const secondMinRec = (arr, len) => {
if (len < 2) {
return [arr[0] ?? Infinity, Infinity];
}
const rec = secondMinRec(arr, len - 1);
const current = arr[len - 1];
if (current < rec[0]) {
rec[1] = rec[0];
rec[0] = current;
} else {
rec[1] = Math.min(rec[1], current);
}
return rec;
}
const secondMin = (arr) => secondMinRec(arr, arr.length)[1];