Кто сможет обьяснить как получилось именно 5

Welcome to the forums.

Please post the code you have tried so far and a written description of what you would like help with.

салам вот код
let matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
];

alert( matrix[1][1] ); // 5, центральный элемент

как тут получилось 5 не понимаю

Indexing into arrays starts at 0 in most programming languages. So, matrix[0][0] is 1, matrix[0][1] is 2, and matrix[1][0] is 4. This means that matrix[1][1] is 5.

я не понел есть вк ? го по звонку обьяснишь

I don’t understand what you are asking.

Indexing into an array always starts at 0.

let matrix = [1, 7, 2]; 
// matrix[0] == 1
// matrix[1] == 7
// matrix[2] == 2

And for a 2d array this pattern continues

let matrix = [
  [1, 7, 2],
  [5, 9, 8],
  [3, 4, 6]
]; 
// matrix[0][0] == 1
// matrix[0][1] == 7
// matrix[0][2] == 2
// matrix[1][0] == 5
// matrix[1][1] == 9
// matrix[1][2] == 8
// matrix[2][0] == 3
// matrix[2][1] == 4
// matrix[2][2] == 6
1 Like