showing results for - "javascript find the second highest element from array"
Gena
24 Sep 2020
1var secondMax = function (){ 
2    var arr = [20, 120, 111, 215, 54, 78]; // use int arrays
3    var max = Math.max.apply(null, arr); // get the max of the array
4    arr.splice(arr.indexOf(max), 1); // remove max from the array
5    return Math.max.apply(null, arr); // get the 2nd max
6};
7
Emily
10 Oct 2016
1var secondMax = function (arr){ 
2    var max = Math.max.apply(null, arr), // get the max of the array
3        maxi = arr.indexOf(max);
4    arr[maxi] = -Infinity; // replace max in the array with -infinity
5    var secondMax = Math.max.apply(null, arr); // get the new max 
6    arr[maxi] = max;
7    return secondMax;
8};
Youna
03 Jan 2021
1var secondMax = function (){ 
2    var arr = [20, 120, 111, 215, 54, 78]; // use int arrays
3    var max = Math.max.apply(null, arr); // get the max of the array
4    arr.splice(arr.indexOf(max), 1); // remove max from the array
5    return Math.max.apply(null, arr); // get the 2nd max
6};
Damien
10 Nov 2020
1['20','120','111','215','54','78'].sort(function(a, b) { return b - a; })[1];
2// '120'
3
queries leading to this page
how to find second largest element of an arrayfind second largest number in javascriptfind the 2nd largest number in an array in jsreturn second largest element in an arrayhow to find second highest element in arrayfind second highest number in array in javascriptfind the second largest nunver in an array using javascriptfind second largest number in array without sorting javascriptfind second largest number in javascript without arrayascending order second biggest number in array javascriptfind second highest number in arrayhow to find the second highest number in array in javascriptsecond highest number in array js without methodhow to find the two biggest value in an array in javascripthow to get the 2nd largest number in array jsget the second highest number of an array jsfind second largest number in an array using single loop javascripthow to get the second highest from an array in javascriptcount the third biggest number javascriptfind second max number in arrayfind the second highest salary in array in jsfind 2nd largest number in array javascripthow to find second largest elemt in array jshow to find the second largest string in an array in javascriptfind two largest numbers in array javascriptfind max value second max value and third max value for 3 number in jsget second largest number from array jssecond largest number in array es6how to find second largest number in javascript without using arrayfinding the second largest number in an array javascripthow to find second largest no in an arraypull second largest value in array javascript4 find the second highest element of the array using inbuild functions in javascripthow to find second largest element in arrayhow to find second max number in array js without use built in functionhow do you find the 2nd largest number in an array in javascriptget second highest number in array javascripthow to find a second highest number in larger size array javascripthoe w to take the second laregest value in jqueryjs how d0 i get the second largest element fromhow to find 2nd max number of an array in javascriptthe second largest number in js find the second highest element of the array using inbuild functions javascripthow to find second largest number in arraysecond lowest and second highest number in an array javascriptsecond largest number in array javascript without inbuilt functionfind largest and second largest number of an array in javascripthow to find second highest number form an arrayget second largest number from arrayfind the second largest and second smallest in an array in javascriptarray second highest numberfind the second smallest number in an array javascriptjs second largestfind the second highest element of the array using inbuilt function in javascripfind second largest element in arrayfind the second highest number in an arrayjs get second largest number in arrayfind second largest number in array javascript using for looparray second highest number jssecond largest element in arrayget second largest number in array javascriptsecond highest number in array javascript without maxsecond greatest lowest in array in javascriptsecond highest value in array jssecond largest number of an array in javascriptjavascript method to find second smallest numbermaxlength of 1d array in mutideimentional array jsjavascript find the second highest element from arraysecond highest value in arrayhow to get the second max num in js arrayjavascript program to find second largest number in an array use inbuild methodjs find second largest number in arrayhow to get max value manual in array using javascript2nd max digit of an array javascriptjavascript get 2 largest number in arrayfind second largest number in array in javascript programerizesecond largest elements in an array in javasriptfind the second largest number javascriptfind second largest number in array javascript using if elsesecond max number in arrayfind second largest number in arrayreturn 2nd highest value javascripthow to get second largest number in an array javascriptfind second largest number in three numbers javascriptsecond largest number jsfind second maximum number in array in javascriptsecond highest number in array jsfind second largest element in the arrayhow to print 2nd largest number in javascriptfind nth largest number in array in javascriptfind the second largest number in an array of integers java scriptarray find second largest number javascript using no functionjavascript get second highest value in arrayjavascript program to find second largest number in an arraymaxlength in mutideimentional array jssecond largest number in array in javascriptsecond highest in an array2nd highest number in array in jshow to get the max row in an array javascripthow to find second maximum element in an arrayjavascript array second max valuehow to get second largest value with an array in javascriptfind the third largest number in an array using javascripthow to find max and second max in jshoe to find second highest no in arrayjavascript get second largets value from arraysecond largest number formed in an array typescriptjavascript code to find second largest element in an arraysecond largest number in jshow to find second largest number in an array vanilla jshow to find 2nd largest number in array in javascriptsecond largest in array javascripthow do you find second max number from an array in jshow to find second max number in arrayjs how do i get the second largest element fromget second largest number in integer jsjs array second maxsecond largest number in array javascript without sortingjavascript second largest numberjavascript second highest value in arrayjavascript program to find the second largest number in an arraysecond largest nr in a array javascriptnth largest and smalest number in array javascripthow to get second largest number in an arrayfind the second largest number in arrayfind second largest number in array using javascript without using built in functionfind third largest number in array javascripthow do you find the second highest number in an integer arrayarray second largest numberin array find second largest numberhow to find second largest number from array in javascriptsecond largets element in array jsfind the second largest element from an array in javascriptsecond largest number in array if there is two equal javascriptfind 2nd largest number in array in jssecond big number in array in javascriptsecond largest element in array using loop javascriptcount the second largest no in javascript2nd largest element in array jsfind the second largest number in an array javascript using loopto find the second largest number in an arraysecond largest array value javascriptsecond largest number in javascriptarray second highest and lowest number jsjs array find second largest elementhow to find second largest number from arrayjavascript find second max value in arrayjavascript find third largest number in arrayfind second largest number in array using javascriptjavascriptget 2 largest number in array2nd highest element in array jshow to find second largest number in an arrayhow to find the second highest value in an array without math in javascripthow to print second largest number in array in javascriptfind second largest in arrayjs how do i get the second largest element from an array in javascript let arr1 3d 5b 2720 27 2c 27120 27 2c 27111 27 2c 27215 27 2c 2754 27 2c 2778 27 5d 3b 5dsecond largest item jsfind second largest number in array javascripthow to find the second highest number in javascriptfind second largest number in array in javascript2nd largest number in array javascriptfind second largest number in array on length in javascriptsecond highest number in arrayreturn the highest 2 value in an array javascriptsecond largest variable in array jsfind nth largest number in array without sorting in javascriptfind kth largest element in array js tcfind the maximum and second maximum number in an array of integers jsjs find second max occurrence of a number in an array get second smallest value in array javascriptsecond highest number in array js without using method in arrayfind third lowest in array jssecond max value in an arrayhow to find the second largest number in an array in javascripthow to find second the minimum number from an array javascriptarray finding second same element in jsfind second minimum in array javascriptreturn the third largest element in an array jscalculate second lowest number in array in jsjavascript program to find second largest element in an array of integerssecond largest element in an array in javascripthow to find the second largest number in javascriptfind second largest number in an arrayhow to find the 2nd highest elemt of an array jsfunction find largest number in array jshow to find second max number in array jshow to return second max value in array in javascriptsecond largest element in array jsfind second largest element in an arrayhow to get the second biggest number from a arrayfind second largest number from an array in javascriptreturn the second highest number in the arraysecond largest number in an array javascriptfind second highest value in array jsfind the second max element in arraynth largest number in array javascripthow to get the second max value of an array in javascriptsecond largest number in array jshow to find the 2nd largest number in an array javascriptgetsecondlargest 28 29 array jsfind second highest number in numeric array javascripthow to get second largest element in an array javascriptfind the second highest value in an array jsjs secondlargestfinding second largest element in an arraysecond highest number in array js without using methodfind second largest value in array javascriptfind second biggest number in arrayfind the second largest number from array using javascripthow to get second largest number in integer in jscalculate second highest number in array in jssecond highest number in array javascripthow to find second largest number in array in jssecond highest in arraythird largest number in array jssecond largest number jssecond lowest array value in js finding nth largest number from array in javafind 2nd number in array object javascriptfind the second largest number in jssecond highest number in an arrayfind the second largest number in an array javascript best solutionhow do you find the second largest number in an unsorted integer array in jshow to find second max element in an arrayfind the second largest number in an array of integers javascriptlargest 2 number array javascriptsecond max arrayget second largest value from arrayjs array find second largesthow to return second largest value in array in javascriptjs code for second largest number in arrayfind second max value in an arrayfind the second largest number in an array javascriptfind the second largest number in an arrayfinding second lowest array element in javascriptjs code to fing second largest number in an arraywrite a javascript function that finds second largest number in array2nd greatest number in array javascripthow to get the second largest num in arrayreturn the second largest number in the array javascriptfinnd the second largest number in an array of integers java scriptfind second highest number in array javascriptsecond largest number in array javascripthow to find second max number in array js without use built in function js find second largest number in array from largestjavascript code to find second largest element in an array without functionjavascript get second largestfind second largest number of array in javascriptreturn the biggest and second biggest number from an array javascriptjavascript print second largest from arraysecond largest jshow to find second lowest value in array using javascriptfind the second largest number in array get the second largest element in an arrayhow to find the second highest value in an array in jshow to find second highest number in arrayhow to get second largest number from integer in jsa program to find 2nd largest number in javascript write a function which takes an array of integers given as string as an argument and returns second max value from the input array in javascripthow to find the second largest number in javascripthow to find second largest number in javascriptdifferent ways to find 2nd largest number in a array in javascriptuse javascript to find the second largest number in an array in htmljavascript returns second largest number in arrayfunction to find second largest element in an arrayfind second largest number in array using for loop javascriptfind largest five number in array javascriptsecond largest element in array in javascriptfind second highest element in an arrayfind second lowest number in array javascriptfind the 2nd largest number in an array js find second smallest number in array javascripthow to find the 2nd highest elemt of an arrayjavascript array find second smallest numberfind the second largest number in an array in javascriptjs get two max value from arrayhow to find second largest no in arrayfind second largest number in array in jsjs sort with highest at top and second highest at endget second largest number from array javascriptfind max and second max in arrayhow to find the second maximum number in an array jsfind second largest in array on length in javascriptfind second max value in array javascriptcreate an array to find 2nd max number in javascriptfind max and 2nd max in arrayfind second highest in array in jsjavascript get second largest value from arraysecond largest and second smallest element in array in javascripthow to find second highest number form an array in jsfind l second largest number in array jsreturn the second largest element from an unsorted array in jshow to find 2nd largest number in array javascripthow to find the second largest number in an array in jsreturn the second largest number in the arraysecond max value in an array javasciprtto find second largest element in arrayfind second largest number in array without sorting in javascritfind the second largest number in an array javascript if there is no second max return 1find the second highest number in array in jssecond largest number in array using math maxhow to find 2nd highest number in arraysecond max in arrayefficient way to find second maximum in arraysecond largest element in array javascriptsecond largest element in array without sorting javascriptfind the largest two numbers in a given array in javascripthow to get second max number in an array using jsreturn second largest element in an array javascriptsecond highest element in arrayfind second largest number from an array in javascript if largest having duplicate entrtjavascript program to find second lowest and second highest number in arrayfind second largest element jsget 2nd highest number in array javascriptfind second highest value in array javascriptjavascript second largest number in arrayfind second largest number in javascript without using arrayfind largest number in array jswrite a program to find second highest number in an array in javascripthow to get the second largest number in an array in javascripthow to find 2nd largest element in an array javascripthow to find third smallest and second highest element of array in jsfind the second smallest element from an array in javascripthow to find second largest number in array javascriptfind the second highest element of the array using inbuild functions in jsfind second greatest no in jsjavascript find 2nd largest number in arrayjavascript find second largest number in arrayhow to find second largest number in array in javascriptget second largest number from array js es6how to find the second largest number in an array javascript javascript find the second highest element from array