Computer Science, asked by 8888284683vp, 4 months ago

1. Write a JavaScript function which will take an array of numbers stored and find the second lowest and second highest numbers, respectively.

Answers

Answered by jai696
6

\huge\red{\mid{\fbox{\tt{Using\: JavaScript}}\mid}}

const secondLowest = arr => arr.sort((a, b) => a - b)[1]

const secondLargest = arr => arr.sort((a, b) => b - a)[1]

let arr = [365, 253, 755, 296, 108, 613, 334, 47, 623, 567]

console.log(`second lowest: ${secondLowest(arr)}\nSecond largest: ${secondLargest(arr)}`)

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions