Я работаю над домашним заданием, но застрял в одной части.Я хочу иметь возможность получать каждый 3-й элемент из каждого массива во вложенном массиве.
const movies = [
[`Harry Potter and the Philosopher's Stone`, 125000000, `dCtFvscYcXQKTNvyyaQr2g2UacJ`, 152, 2001, `Let the Magic Begin`],
[`Harry Potter and the Chamber of Secrets`, 100000000, `sdEOH0992YZ0QSxgXNIGLq1ToUi`, 161, 2002, `Hogwarts is back in session`],
[`Harry Potter and the Prisoner of Azkaban`, 130000000, `jUFjMoLh8T2CWzHUSjKCojI5SHu`, 141, 2004, `Something wicked this way comes`],
[`Harry Potter and the Goblet of Fire`, 150000000, `6sASqcdrEHXxUhA3nFpjrRecPD2`, 157, 2005, `Dark And Difficult Times Lie Ahead`],
[`Harry Potter and the Order of the Phoenix`, 150000000, `4YnLxYLHhT4UQ8i9jxAXWy46Xuw`, 138, 2007, `Evil Must Be Confronted`],
[`Harry Potter and the Half-Blood Prince`, 250000000, `bFXys2nhALwDvpkF3dP3Vvdfn8b`, 153, 2009, `Dark Secrets Revealed`],
[`Harry Potter and the Deathly Hallows: Part 1`, 250000000, `maP4MTfPCeVD2FZbKTLUgriOW4R`, 146, 2010, `One Way… One Fate… One Hero`],
[`Harry Potter and the Deathly Hallows: Part 2`, 125000000, `fTplI1NCSuEDP4ITLcTps739fcC`, 130, 2011, `It all ends here.`]
];
let filteredArray = []
let filter = () => {
for (j = 0; j < movies.length; j++) {
filteredArray.push(movies[j][2]);
}
}
console.log(filteredArray);
Мой план состоял в том, чтобы получить отфильтрованный массив только из 3-х элементов, поэтому в основном это отфильтрованный массив из старого.,Я пытался использовать .filter, но я не могу понять, как, поэтому, если ваше решение использует .filter, это очень приветствуется.
Мой вывод в консоли просто дает мне пустой массив, и если я утешаю.войти в фильтр функций, он дает мне неопределенный.