📜  在数组 javascript 代码示例中查找第二大数字

📅  最后修改于: 2022-03-11 15:03:31.642000             🧑  作者: Mango

代码示例5
const arr = ['20','120','111','215','54','78', '120'];   
let intArray = arr.map(Number); // convert into number
intArray = [...new Set(intArray)]; // Remove duplicate numbers
const secondLargestNumber = intArray.sort((a,b) => {
   return b - a;
})[1];
console.log(secondLargestNumber) // 120