<sectionid="description"><code>Array.prototype.reduce()</code> или просто <code>reduce()</code>, является наиболее общей из всех операций с массивами в JavaScript. Вы можете решить практически любую проблему обработки массива с помощью метода <code>reduce</code> . Это не относится к методам <code>filter</code> и <code>map</code> поскольку они не позволяют взаимодействовать между двумя различными элементами массива. Например, если вы хотите сравнить элементы массива или добавить их вместе, <code>filter</code> или <code>map</code> не смогут обработать это. Метод <code>reduce</code> позволяет использовать более общие формы обработки массивов, и можно показать, что как <code>filter</code>, так и <code>map</code> могут быть реализованы через <code>reduce</code>. Однако, прежде чем мы перейдем к этому, давайте сначала научимся использовать <code>reduce</code>. </section>
<sectionid="instructions"> Переменная <code>watchList</code> содержит массив объектов с информацией о нескольких фильмах. Используйте <code>reduce</code> чтобы найти средний рейтинг IMDB фильмов <strong>режиссера Кристофера Нолана</strong>. Вспомните предыдущие задачи, как применять к данным <code>filter</code> и <code>map</code>, чтобы вытащить то, что вам нужно. Возможно, вам придется создавать другие переменные, но сохранить окончательное среднее значение в переменной <code>averageRating</code>. Обратите внимание, что значения рейтинга сохраняются как строки в объекте и должны быть преобразованы в числа, прежде чем они будут использоваться в любых математических операциях. </section>
- text: Переменная <code>watchList</code> не должна изменяться.
testString: 'assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", "The <code>watchList</code> variable should not change.");'
"Actors": "Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen Page, Tom Hardy",
"Plot": "A thief, who steals corporate secrets through use of dream-sharing technology, is given the inverse task of planting an idea into the mind of a CEO.",
"Language": "English, Japanese, French",
"Country": "USA, UK",
"Awards": "Won 4 Oscars. Another 143 wins & 198 nominations.",
"Writer": "Jonathan Nolan (screenplay), Christopher Nolan (screenplay), Christopher Nolan (story), David S. Goyer (story), Bob Kane (characters)",
"Actors": "Christian Bale, Heath Ledger, Aaron Eckhart, Michael Caine",
"Plot": "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice.",
"Language": "English, Mandarin",
"Country": "USA, UK",
"Awards": "Won 2 Oscars. Another 146 wins & 142 nominations.",
"Writer": "Bob Kane (characters), David S. Goyer (story), Christopher Nolan (screenplay), David S. Goyer (screenplay)",
"Actors": "Christian Bale, Michael Caine, Liam Neeson, Katie Holmes",
"Plot": "After training with his mentor, Batman begins his fight to free crime-ridden Gotham City from the corruption that Scarecrow and the League of Shadows have cast upon it.",
"Language": "English, Urdu, Mandarin",
"Country": "USA, UK",
"Awards": "Nominated for 1 Oscar. Another 15 wins & 66 nominations.",
"Actors": "Sam Worthington, Zoe Saldana, Sigourney Weaver, Stephen Lang",
"Plot": "A paraplegic marine dispatched to the moon Pandora on a unique mission becomes torn between following his orders and protecting the world he feels is his home.",
"Language": "English, Spanish",
"Country": "USA, UK",
"Awards": "Won 3 Oscars. Another 80 wins & 121 nominations.",