Hello,

I was working on the basic algorithm challenge in the title and I want to know how it can be best completed and if you can finish it off with my code. I imagine it would be better to use map.() reduce() filter() functions but I do not understand how to use them yet.

function largestOfFour(arr) {

// You can do this!

var finalArr = [[], [], [], []];

var highestNum = 0;

var index = 0;

var stringToArray = “”;

do {

for (i=0;i<arr.length;i++)

{

for (j=0; j<arr[i].length; j++)

{

if (arr[i][j] > highestNum)

{

highestNum = arr[i][j];

finalArr[index][0] = highestNum;

}

}

index++;

}

} while (index < finalArr.length);

for (i=0; i<finalArr.length; i++)

{

for (j=0; j<finalArr[i].length; j++)

{

stringToArray += finalArr[i][j] + “,”;

}

}

var arrayToString = stringToArray.split(",");

arrayToString.pop();

for (i=0;i<arrayToString.length;i++)

{

for (k=0; k<finalArr.length;k++)

{

for (l=0; l<finalArr[k].length; l++)

{

finalArr[k][l] = arrayToString[i];

}

}

}

return finalArr;

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);