Largest Numbers in Arrays Help

i dont understand why i got this error
TypeError: Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a Symbol.iterator method.

Your code so far


function largestOfFour(arr) {

 for(var i=0; i<arr.length;++i , arr.shift()){
   
         arr.push(Math.max(...arr[i]));
 }
  console.log(arr);
return arr;
}

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

Your browser information:

Challenge: Return Largest Numbers in Arrays

Link to the challenge:

You are pushing single numbers onto your input array, and your loop goes over the entire length of your input array. You therefore will attempt to use the spread syntax on single numbers.

I would put your results in a brand new array. You don’t really want to modify an array as you iterate over it, in general.