find second largest number in array javascript

Solutions on MaxInterview for find second largest number in array javascript by the best coders in the world

showing results for - "find second largest number in array javascript"
Hayes
16 Jun 2018
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
Carl
13 May 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};
Alberto
04 Jun 2016
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};
Chiara
27 Aug 2017
1const arr = ['20','120','111','215','54','78', '120'];   
2let intArray = arr.map(Number); // convert into number
3intArray = [...new Set(intArray)]; // Remove duplicate numbers
4const secondLargestNumber = intArray.sort((a,b) => {
5   return b - a;
6})[1];
7console.log(secondLargestNumber) // 120
Ivan
26 Mar 2017
1['20','120','111','215','54','78'].sort(function(a, b) { return b - a; })[1];
2// '120'
3
queries leading to this page
find second highest element in an arraysecond largest variable in array jshow to get the second max value of an array in javascriptjavascript print second largest from arrayhow do you find the second largest number in an unsorted integer array in jsjs sort with highest at top and second highest at endfind second largest number in array javascript using for loopjavascript find second largest number in arrayjavascript get second highest value in arrayfinding second lowest array element in javascriptfind the second largest number in an array javascript if there is no second max return 1second lowest array value in js js 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 5dhow to find second largest number in array in jssecond largest array value javascriptsecond largest number in javascriptget 2nd highest number in array javascriptfind second largest number in javascript without using arrayfind second largest number in array without sorting javascriptin array find second largest numberjavascript returns second largest number in arrayjs code for second largest number in arrayfind the second largest and second smallest in an array in javascriptjavascript find third largest number in arraysecond largest element in an array in javascripthow to get second largest number in an array javascriptfind the second largest number in an array javascriptget second largest number from array jshow to return second largest value in array in javascripthow to find second highest number form an arrayhow to find second largest number in arrayfind second largest number from an array in javascriptfind second smallest number in array javascriptarray finding second same element in jsfinnd the second largest number in an array of integers java scripthow to get second largest number from integer in jsfind the second max element in arrayhow to get the second biggest number from a arrayfind two largest numbers in array javascriptfind the second largest number in an array of integers java scriptfind second largest number in array javascript using if elsefind second largest number from an array in javascript if largest having duplicate entrtfind the second highest value in an array jshow to find second largest number from array in javascripthow to get the 2nd largest number in array jsfind largest five number in array javascriptsecond lowest and second highest number in an array javascriptarray second highest and lowest number jsarray second highest number jsjs how d0 i get the second largest element fromhoe w to take the second laregest value in jqueryhow to find second max element in an arraysecond largest element in array in javascriptfind the second smallest number in an array javascriptjavascript program to find the second largest number in an arrayhow to find the second maximum number in an array jshow to find 2nd largest element in an array javascriptfind the second highest number in array in jshow to find 2nd largest number in array in javascripthow to find max and second max in jsreturn the second largest element from an unsorted array in jssecond greatest lowest in array in javascriptfind 2nd number in array object javascripthow to find the second largest string in an array in javascriptsecond largest item jsjavascript second largest numberhow to get second largest element in an array javascriptnth largest and smalest number in array javascriptsecond max number in arrayfind second largest number in arrayfind second largest number in array using javascript without using built in functionhow to find second largest element of an arrayjavascript get second largesthow to find the second largest number in an array javascript write a program to find second highest number in an array in javascriptfind second largest in arrayfind the second highest element of the array using inbuilt function in javascripfind second highest number in array in javascriptfind second largest number in array on length in javascriptsecond largest element in array javascriptfind the second largest number in an array javascript best solutionsecond largest number in array jsfind the third largest number in an array using javascriptreturn second largest element in an array javascripthow to find second largest number in javascriptsecond largest in array javascriptsecond max value in an array javasciprtsecond highest number in array js without using method in arrayfind largest and second largest number of an array in javascriptfind kth largest element in array js tchow do you find second max number from an array in jswrite a javascript function that finds second largest number in arraysecond highest element in arrayhow to get second largest number in integer in jsfind second greatest no in jsfind max and second max in arrayhow to find 2nd max number of an array in javascriptreturn the second largest number in the array javascripthow to find second largest number in array in javascript2nd largest number in array javascriptfind second largest number in three numbers javascriptfind the second largest number in an array javascript using loopget second largest number from arrayhow to get the second largest number in an array in javascripthow to find second max number in arrayhow to find second largest element in arrayfind third largest number in array javascriptarray second largest numberhow to find third smallest and second highest element of array in jsjavascript array find second smallest numberfind the second largest number in an array of integers javascripthow to find second largest number in javascript without using arrayhow to find second largest number in an arraymaxlength of 1d array in mutideimentional array jssecond highest number in array js without method2nd max digit of an array javascriptsecond big number in array in javascriptsecond largest and second smallest element in array in javascriptfind second highest number in arrayhow to find the 2nd highest elemt of an array jsfind second largest number in javascript without arrayhow to get the second highest from an array in javascriptreturn the third largest element in an array jsto find second largest element in arrayfind second largest number in javascriptarray second highest numberjavascript program to find second largest number in an array use inbuild methodget second highest number in array javascriptjavascript find 2nd largest number in arrayfind second highest in array in jshow to get second largest value with an array in javascriptjavascript second highest value in array2nd greatest number in array javascripthow to find the second highest value in an array in jsfind second max value in an arraysecond largest number in array if there is two equal javascriptfind 2nd largest number in array in jsreturn the second highest number in the arrayfind second maximum number in array in javascriptsecond largest element in array2nd highest number in array in jsfind the second largest element from an array in javascriptjs find second largest number in array from largestsecond max value in an arrayget the second highest number of an array jscount the second largest no in javascriptjavascript program to find second largest number in an arrayfind second largest value in array javascripthow to find the second highest number in javascriptfind the maximum and second maximum number in an array of integers jsfind second largest element in arrayhow to find second largest elemt in array jshow to find the second largest number in an array in jsfind second largest number in an arrayjavascript program to find second lowest and second highest number in arrayhow to find second the minimum number from an array javascriptlargest 2 number array javascriptfind second highest number in numeric array javascriptreturn the second largest number in the arraysecond largest number in an array javascripthow to find second largest no in an arrayuse javascript to find the second largest number in an array in htmlget second largest number in integer jssecond highest value in arrayjavascript array second max valuefinding nth largest number from array in javareturn the highest 2 value in an array javascripthow to find second highest number in arraysecond largest number in jspull second largest value in array javascripthow to print 2nd largest number in javascript2nd highest element in array jsfind third lowest in array jssecond highest value in array jsfind second lowest number in array javascriptfind the second largest number in array find second largest element in an arrayjavascript find second max value in arrayfind second largest number in array without sorting in javascritfind the second highest number in an arrayhoe to find second highest no in arrayjs find second max occurrence of a number in an array different ways to find 2nd largest number in a array in javascripthow to find second lowest value in array using javascriptjs secondlargestfunction find largest number in array jshow to find second highest number form an array in jsfind the second largest nunver in an array using javascriptfind the second largest number in an arraysecond largest number formed in an array typescripthow to return second max value in array in javascriptsecond largest elements in an array in javasriptfind the second largest number in jsthe second largest number in jsfind second largest number in array in javascriptsecond largest number in array javascriptreturn second largest element in an arraysecond highest number in array javascriptget second largest number in array javascriptfind 2nd largest number in array javascriptfind second max value in array javascriptjs find second largest number in arrayhow to find the second largest number in an array in javascriptfind the largest two numbers in a given array in javascriptfind the second largest number in an array in javascriptreturn 2nd highest value javascriptgetsecondlargest 28 29 array jsfunction to find second largest element in an arraysecond largest number in array in javascripthow to find the 2nd highest elemt of an arrayfind the 2nd largest number in an array js how to find the 2nd largest number in an array javascriptsecond largest number jsfind second highest number in array javascriptascending order second biggest number in array javascriptsecond largest nr in a array javascriptfind second largest number of array in javascriptjs code to fing second largest number in an arrayget the second largest element in an arrayjavascript find the second highest element from arrayfinding second largest element in an arrayjavascript code to find second largest element in an arrayfind second highest value in array jssecond largest number jssecond highest number in array javascript without maxfind second largest element jsmaxlength in mutideimentional array jssecond largest number of an array in javascriptjavascript program to find second largest element in an array of integershow to find second largest no in arraysecond largest element in array without sorting javascriptcalculate second highest number in array in jssecond highest number in an arrayfind the second highest salary in array in jsfind second minimum in array javascriptfind the second highest element of the array using inbuild functions in jshow to find the second highest value in an array without math in javascript2nd largest element in array jshow to find the two biggest value in an array in javascriptfind second largest number in array javascriptjs array find second largest elementsecond largets element in array jsnth largest number in array javascriptfind second largest number in array in jshow do you find the second highest number in an integer arraysecond largest number in array es6find second largest number in an array using single loop javascripthow to find second largest number from arrayfind second largest number in array using for loop javascriptfind second largest number in array using javascriptfind second highest value in array javascriptfind second max number in arrayjs array find second largestcalculate second lowest number in array in jshow to print second largest number in array in javascriptfinding the second largest number in an array javascriptefficient way to find second maximum in arrayhow to find second maximum element in an arraya program to find 2nd largest number in javascriptto find the second largest number in an arraysecond largest element in array jssecond highest number in array jsget second smallest value in array javascriptthird largest number in array jshow to find second highest element in arrayjs array second maxhow to find a second highest number in larger size array javascriptjavascript second largest number in array 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 javascriptsecond highest number in array js without using methodfind second largest in array on length in javascriptfind second largest number in array in javascript programerizejs second largestfind largest number in array jshow to find second largest number in array javascriptsecond highest in an arrayget second largest number from array javascripthow to find second largest number in an array vanilla jsfind max and 2nd max in arrayfind the second smallest element from an array in javascriptsecond largest jsreturn the biggest and second biggest number from an array javascriptsecond largest element in array using loop javascriptget second largest number from array js es6js how do i get the second largest element fromsecond highest number in arrayhow to find the second largest number in javascriptfind the second largest number javascriptsecond largest number in array using math maxfind second largest number in array javascript