JSFiddle - React, Tailwind, and code Playground

JavaScript

function solve(arr) {

  const acc = [];
  let max = 1;

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

    for (let j = 0; j < arr[i].length; j++) {
      acc.push(arr[i][j] * max);
      console.log(max) // ??  как max становиться равным 2
    }

    max = Math.max(...acc);
  }

  return max;

}

console.log(
  solve([
    [1, 2],
    [3, 4],
  ])
); // 8