Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Write a JavaScript function to get nth largest element from an unsorted array.

Instructions

Input

nthlargest([ 43, 56, 23, 89, 88, 90, 99, 652], 4)

Output

89

Challenges (0/2 done)

  • nthlargest([ 43, 56, 23, 89, 88, 90, 99, 652], 4) returns 89.
  • nthlargest([ 10, 100, 1000, 10000], 2) returns 1000.
function nthlargest(arr, highest) {
	// write your code here
	return
}

const arr = [43, 56, 23, 89, 88, 90, 99, 652];
const highest = 4;

console.log(nthlargest(arr, highest));