I was been asked in an interview to code for the following scenario.
var ele = [2,5,4,8,4,9].second();
If the above statement is written in javascript it ele should contain second highest element from that array. In this case it should contain 8.
how do you write the code for this? I assume we will have to write a function second()
but how do we call make sure it takes the array as that parameter?
Please help me with this. Thank You in advance.