We are required in our assignment to find the second smallest integer in one array recursively. However, for the sake of understanding the subject more, I want to do it iter
I've used Sort function in javascript
function sumTwoSmallestNumbers(numbers){
numbers = numbers.sort(function(a, b){return a - b; });
return numbers[0] + numbers[1];
};
by providing a compareFunction
for the sort functionality array elements are sorted according to the return value of the function.