Simplified a little

Continuing the discussion from freeCodeCamp Algorithm Challenge Guide: Return largest Numbers in Arrays:

I simplified it a little
function largestOfFour(arr) {
// You can do this!
var max=[];
for (var i= 0; i<arr.length;i++)

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

  } //for

return max;

} //function

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.

We have set your post to unlisted. Thanks for your understanding.

1 Like

Ok, I am sorry, I am new to the fcc community.

i know this is old one but i am just learning here, i tried this code and it did work.
i dont think i am that genius so here it is:

function largestOfFour(arr) {

  return =>{

    return Math.max(...x)



//Used the inbuilt Math.max function with the spread operator for a simple solution
function largestOfFour(arr) {

var a=[ ]
for(let i=0;i<arr.length;i++)
var max=Math.max(…arr[i])
return a
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);