const arr = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[[10, 11, 12], 13, 14]
];
const subArray = arr[3,1];
console.log(subArray);
what’s rule so i can prefer to 13.
and what’s meaning of this [[10, 11, 12], 13, 14] and thanks.
const arr = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[[10, 11, 12], 13, 14]
];
const subArray = arr[3,1];
console.log(subArray);
what’s rule so i can prefer to 13.
and what’s meaning of this [[10, 11, 12], 13, 14] and thanks.
const arr = [
[1, 2, 3],
[4, 5, 6],
[7, 8 , 9],
[
[10, 11, 12],
13,
14,
],
];
arr is an array.
Its first item is [1, 2, 3]
Its second item is [4, 5, 6]
Its third item is [7, 8, 9]
Its fourth item is [[10, 11, 12], 13, 14]
The first three items are all arrays of numbers. The fourth item is a little different. Its first item is another array of numbers, while the following items (13 and 14) are simply numbers.
Hi,
I think you are asking how you would access the element ‘13’ in the ‘arr’ variable? If so, you are just slightly off with the syntax:
const subArray = arr[3,1] should be const subArray = arr[3][1]
I hope that helps!
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.