SHARE
TWEET

Untitled

a guest Jul 18th, 2019 130 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // the global variable
  2. var watchList = [
  3.                  {  
  4.                    "Title": "Inception",
  5.                    "Year": "2010",
  6.                    "Rated": "PG-13",
  7.                    "Released": "16 Jul 2010",
  8.                    "Runtime": "148 min",
  9.                    "Genre": "Action, Adventure, Crime",
  10.                    "Director": "Christopher Nolan",
  11.                    "Writer": "Christopher Nolan",
  12.                    "Actors": "Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen Page, Tom Hardy",
  13.                    "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.",
  14.                    "Language": "English, Japanese, French",
  15.                    "Country": "USA, UK",
  16.                    "Awards": "Won 4 Oscars. Another 143 wins & 198 nominations.",
  17.                    "Poster": "http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1_SX300.jpg",
  18.                    "Metascore": "74",
  19.                    "imdbRating": "8.8",
  20.                    "imdbVotes": "1,446,708",
  21.                    "imdbID": "tt1375666",
  22.                    "Type": "movie",
  23.                    "Response": "True"
  24.                 },
  25.                 {  
  26.                    "Title": "Interstellar",
  27.                    "Year": "2014",
  28.                    "Rated": "PG-13",
  29.                    "Released": "07 Nov 2014",
  30.                    "Runtime": "169 min",
  31.                    "Genre": "Adventure, Drama, Sci-Fi",
  32.                    "Director": "Christopher Nolan",
  33.                    "Writer": "Jonathan Nolan, Christopher Nolan",
  34.                    "Actors": "Ellen Burstyn, Matthew McConaughey, Mackenzie Foy, John Lithgow",
  35.                    "Plot": "A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival.",
  36.                    "Language": "English",
  37.                    "Country": "USA, UK",
  38.                    "Awards": "Won 1 Oscar. Another 39 wins & 132 nominations.",
  39.                    "Poster": "http://ia.media-imdb.com/images/M/MV5BMjIxNTU4MzY4MF5BMl5BanBnXkFtZTgwMzM4ODI3MjE@._V1_SX300.jpg",
  40.                    "Metascore": "74",
  41.                    "imdbRating": "8.6",
  42.                    "imdbVotes": "910,366",
  43.                    "imdbID": "tt0816692",
  44.                    "Type": "movie",
  45.                    "Response": "True"
  46.                 },
  47.                 {
  48.                    "Title": "The Dark Knight",
  49.                    "Year": "2008",
  50.                    "Rated": "PG-13",
  51.                    "Released": "18 Jul 2008",
  52.                    "Runtime": "152 min",
  53.                    "Genre": "Action, Adventure, Crime",
  54.                    "Director": "Christopher Nolan",
  55.                    "Writer": "Jonathan Nolan (screenplay), Christopher Nolan (screenplay), Christopher Nolan (story), David S. Goyer (story), Bob Kane (characters)",
  56.                    "Actors": "Christian Bale, Heath Ledger, Aaron Eckhart, Michael Caine",
  57.                    "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.",
  58.                    "Language": "English, Mandarin",
  59.                    "Country": "USA, UK",
  60.                    "Awards": "Won 2 Oscars. Another 146 wins & 142 nominations.",
  61.                    "Poster": "http://ia.media-imdb.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_SX300.jpg",
  62.                    "Metascore": "82",
  63.                    "imdbRating": "9.0",
  64.                    "imdbVotes": "1,652,832",
  65.                    "imdbID": "tt0468569",
  66.                    "Type": "movie",
  67.                    "Response": "True"
  68.                 },
  69.                 {  
  70.                    "Title": "Batman Begins",
  71.                    "Year": "2005",
  72.                    "Rated": "PG-13",
  73.                    "Released": "15 Jun 2005",
  74.                    "Runtime": "140 min",
  75.                    "Genre": "Action, Adventure",
  76.                    "Director": "Christopher Nolan",
  77.                    "Writer": "Bob Kane (characters), David S. Goyer (story), Christopher Nolan (screenplay), David S. Goyer (screenplay)",
  78.                    "Actors": "Christian Bale, Michael Caine, Liam Neeson, Katie Holmes",
  79.                    "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.",
  80.                    "Language": "English, Urdu, Mandarin",
  81.                    "Country": "USA, UK",
  82.                    "Awards": "Nominated for 1 Oscar. Another 15 wins & 66 nominations.",
  83.                    "Poster": "http://ia.media-imdb.com/images/M/MV5BNTM3OTc0MzM2OV5BMl5BanBnXkFtZTYwNzUwMTI3._V1_SX300.jpg",
  84.                    "Metascore": "70",
  85.                    "imdbRating": "8.3",
  86.                    "imdbVotes": "972,584",
  87.                    "imdbID": "tt0372784",
  88.                    "Type": "movie",
  89.                    "Response": "True"
  90.                 },
  91.                 {
  92.                    "Title": "Avatar",
  93.                    "Year": "2009",
  94.                    "Rated": "PG-13",
  95.                    "Released": "18 Dec 2009",
  96.                    "Runtime": "162 min",
  97.                    "Genre": "Action, Adventure, Fantasy",
  98.                    "Director": "James Cameron",
  99.                    "Writer": "James Cameron",
  100.                    "Actors": "Sam Worthington, Zoe Saldana, Sigourney Weaver, Stephen Lang",
  101.                    "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.",
  102.                    "Language": "English, Spanish",
  103.                    "Country": "USA, UK",
  104.                    "Awards": "Won 3 Oscars. Another 80 wins & 121 nominations.",
  105.                    "Poster": "http://ia.media-imdb.com/images/M/MV5BMTYwOTEwNjAzMl5BMl5BanBnXkFtZTcwODc5MTUwMw@@._V1_SX300.jpg",
  106.                    "Metascore": "83",
  107.                    "imdbRating": "7.9",
  108.                    "imdbVotes": "876,575",
  109.                    "imdbID": "tt0499549",
  110.                    "Type": "movie",
  111.                    "Response": "True"
  112.                 }
  113. ];
  114.  
  115. // Add your code below this line
  116.  
  117. var filteredList;
  118. var rating;
  119. var onlyRating;
  120. const reducer = (accumulator, currentValue) => accumulator + currentValue;
  121.  
  122. rating = watchList.map( (item) => ({"director": item["Director"], "rating": item["imdbRating"]}));
  123. filteredList = rating.filter(e => test(e));
  124.  
  125. onlyRating = filteredList.map ( (item) => item["rating"]);
  126. onlyRating = onlyRating.map(e => parseFloat(e));
  127. var reducedList = (onlyRating.reduce(reducer) / onlyRating.length);
  128. console.log(reducedList);
  129.  
  130. var averageRating = reducedList;
  131.  
  132.  
  133.  
  134. function test(e){
  135.   return e["director"] == "Christopher Nolan";
  136. }
  137.  
  138. // Add your code above this line
  139.  
  140. console.log(averageRating);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top