Issues of filling multidimensional arrays in JavaScript

Let's consider the following code:

javascriptlet arr = [];

for (let i = 0; i < 3; i++) {
  arr[i] = []; // pay attention to this line
  
  for (let j = 0; j < 3; j++) {
    arr[i].push(j + 1);
  }
}

console.log(arr);

An important place in this code is the creation of an empty subarray. We can't omit this line, because then in the inner loop, an attempt to push data to arr[i] will throw an error.

Задание 1

The author of the following code wanted to make a two-dimensional array:

javascriptlet arr = [];

for (let i = 0; i < 3; i++) {
  for (let j = 1; j <= 5; j++) {
    arr[i].push(j);
  }
}

console.log(arr);

The written code, however, does not do what it was intended. Find and correct the author's mistake.

Задание 2

The author of the following code wanted to make a two-dimensional array:

javascriptlet arr = [];

for (let i = 0; i < 3; i++) {
  arr[i] = '';
  
  for (let j = 1; j <= 5; j++) {
    arr[i].push(j);
  }
}

console.log(arr);

The written code, however, does not do what it was intended. Find and correct the author's mistake.

Задание 3

The author of the following code wanted to make a two-dimensional array:

javascriptlet arr = [];

for (let i = 0; i < 3; i++) {
  arr[i];
  
  for (let j = 1; j <= 5; j++) {
    arr[i].push(j);
  }
}

console.log(arr);

The written code, however, does not do what it was intended. Find and correct the author's mistake.

Задание 4

The author of the following code wanted to make a two-dimensional array:

javascriptlet arr = [];

for (let i = 0; i < 3; i++) {
  arr[j] = [];
  
  for (let j = 1; j <= 5; j++) {
    arr[i].push(j);
  }
}

console.log(arr);

The written code, however, does not do what it was intended. Find and correct the author's mistake.

Задание 5

The author of the following code wanted to make a two-dimensional array:

javascriptlet arr = [];

for (let i = 0; i < 3; i++) {
  arr = [];
  
  for (let j = 1; j <= 5; j++) {
    arr[i].push(j);
  }
}

console.log(arr);

The written code, however, does not do what it was intended. Find and correct the author's mistake.

Задание 6

The author of the following code wanted to make a two-dimensional array:

javascriptlet arr = [];

for (let i = 0; i < 3; i++) {
  arr[i] = [];
  
  for (let j = 1; j <= 5; j++) {
    arr.push(j);
  }
}

console.log(arr);

The written code, however, does not do what it was intended. Find and correct the author's mistake.