I am so close to getting this thing down, but when it comes to negative numbers (passing the last test), I am so dead. If I set the array numbers to negative numbers just to pass the test, then I know I’m cheating. If I empty the array and push the array values in, the final result is always an empty array (totalArr[i].push(arr[i][j]);).

Please helpfully help.

Thanks.

Your code so far

function largestOfFour(arr) {
// You can do this!
var totalArr = [0,0,0,0];
for(var i = 0; i < arr.length; i++){
for(var j = 0; j < arr[i].length; j++){
if(arr[i][j] > totalArr[i]){
totalArr[i]=arr[i][j];
}
}
}
return totalArr;
}
console.log(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

To find them smallest value of the pieces, I’d compare each one to the other(s) as they are handed out to me.

I’ve been reading your explanation over and over for like five minutes, but I’m still totally stuck and am wondering how this relates to the algorithm.

I look at them both and pick the one with the smaller numeric value as the smallest one.

The third piece of paper is given to me.

I look at that one. If its value is greater than that of the previously selected one, then the previous smallest keeps its title of the smallest. If not, then the newest piece of paper is selected as the smallest one.

Finally, the last piece of paper is handed to me. I will compare it with the smallest value I have now. If the piece of paper most recently handed to me has a lesser value than that of the last one, IT will be selected as the smallest one and the algorithm ends. If the paper most recently handed to me has a value greater than that of the last one, then the previous one keeps its title of the lesser of all the others. The algorithm ends.

You told me to find the smallest value of each piece of paper. If you meant to find the largest, then I would go over the same algorithm again and instead of finding the one with the smallest value, try to find the largest.

brother @ConnerOw1115 I solved that same problem by using the Math.max/min methods, I won’t tell you the answer but a little hint: to pass an array to one of these methods do