diff --git a/code.js b/code.js index 1a8bb5c..596791c 100644 --- a/code.js +++ b/code.js @@ -1,4 +1,53 @@ // Your Code Here! +let movieInfo = movies.map(movie => movieDetails.filter(details => details.title === movie.title)); +let movieCatalog = [...movies, ...movieInfo].filter(movie => movie.title !== undefined); + +let movieListDiv = document.getElementById("movieList"); + +let movieCompare = function(movie) { + for (let detail of movieDetails) { + if (movie.title === detail.title) { + return detail.imageUrl; + } + } +} + +let movieListRender = movieCatalog.forEach(movie => { + for (let detail of movieDetails) { + if (movie.title === detail.title) { + movieListDiv.innerHTML += ` +
+ +

${movie.title}

+

Starring: ${movie.cast}

+
Released: ${movie.year}

+
`; + } + } +}) + +let titleSearchButton = document.getElementById("titleSearchButton"); +let titleSearchBar = document.getElementById("titleSearchBar"); + +titleSearchButton.addEventListener("click", () => { + movieListDiv.innerHTML = ""; + movieListRender = movieCatalog.filter(function(movie) { + return movie.title.toLowerCase().includes(titleSearchBar.value.toLowerCase()); + }); + movieListRender.forEach(result => { + for (let detail of movieDetails) { + if (result.title === detail.title) { + movieListDiv.innerHTML += ` +
+ +

${result.title}

+

Starring: ${result.cast}

+
Released: ${result.year}

+
`; + } + } + }); +}); console.log("Movies:", movies); console.log("MovieDetails:", movieDetails); \ No newline at end of file diff --git a/index.html b/index.html index 97e84c4..6933a3c 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,10 @@

Kenzie Movie Catalog

- Write Your HTML Here! + +
+ +
diff --git a/style.css b/style.css index 7e60e49..51569c3 100644 --- a/style.css +++ b/style.css @@ -1 +1,29 @@ /* Write your CSS Here. */ +body { + margin: auto; + width: 100%; + min-width: 700px; + max-width: 800px; +} +input { + margin: 10px 0px; +} + +button { + margin: 10px; +} + +#movieList { + margin: auto; + margin-top: 10px; + display: flex; + flex-wrap: wrap; + justify-content: center; +} + +.movieDiv { + width: 200px; + margin: 10px; + padding: 20px; + border: 1px solid black; +} \ No newline at end of file