Need some hint for this quiz )

my code :

function largestOfFour(arr) {
let firsNumArr1 = arr[0][0];
let firsNumArr2 = arr[1][0];
let firsNumArr3 = arr[2][0];
let firsNumAar4 = arr[3][0];
  for (let i = 0; i < arr.length; i++){
    for (let j = 0 ; j < arr[i].length ; j++ ){


  // You can do this!
  return arr;

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

While you can use two indexes for this one, you really don’t need to. The same as the last time, map out the logic first. You know you’re getting an array containing four members, each of which is an array. You know, from each of those four, you are asked to find the largest number, and store that for later. Let’s see…

  • create a variable to hold an array of largest values
  • loop through the outer array (the one containing the sub-arrays).
    • push that largest value onto the variable we created at step one.
  • finish looping over all the arrays
  • return the array of largest values in each array.

Thanks for helping ) I write code by your plan but code ruturn NaN (

function largestOfFour(arr) {
  // You can do this!
let myArr = [];
for ( let i = 0; i < arr.length; i++ ){

  return arr;

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

perhaps Math.max() must be not in push function ?

Math.max is fine in the push function. The issue is, what you’re feeding into Math.max(). It doesn’t know how to take an array of values and use each one as a parameter.

You know the sub-array will have four members, so each could be found by arr[i][0] (the first number in the i-th array), arr[i][1] etc. So you’d have to put each of these into Math.max() explicitly.

Hey! In that Math.max page I sent, there’s a section on ‘getting the maximum number from an array’ - take a look at that, it might help. :wink:

Research research research.

1 Like

I’m just amazed how easy it can be) I miss your logic)) thanks for the help)

Now I’m not gonna keep giving you the logic outline like that - next time I want to see you show us one! :wink:

It will be hard )
perhaps this is the real work of the programmer, display your logic using the programming language


The “real” programming is maybe ten percent programming. Mostly, it’s researching, and mapping flow, and trying to figure pitfalls before they become a problem.

And, of course, fixing bugs.

you went through the camp to the end ?

Nah. Some of it, some I’m still going. Kind of got un-motivated, and decided to coach for a while and work on some personal projects.