Question d’entretien chez Lokal

Print the second largest element of an array using javascript.

Réponse à la question d'entretien

Utilisateur anonyme

12 mars 2026

Basically, have two variables, one stores the max, another one stores the second max. Iterate over the array, if arr[i] more than current max, then max=arr[i] and second max=max. If arr[i]>second max and arr[i]