somebody please tell me what is the problem with this code ,it is a code to find the largest of the four arrays.I have mentioned
var farray = [];
var ans = [];
function largestOfFour(arr) {
for (i=0;i<arr.length;i++){
farray.push(arr[i].sort());
ans.push(farray[i][3]);
}
return ans;
}
largestOfFour(([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]));
Tests to satisfy:-
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return an array.
largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return [27,5,39,1001].
largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) should return [9, 35, 97, 1000000]