diff --git a/array_challenges.js b/array_challenges.js index 3e3c564..a168f64 100644 --- a/array_challenges.js +++ b/array_challenges.js @@ -1,4 +1,3 @@ - /* The Dataset: Movie Mania @@ -13,15 +12,20 @@ You are managing a database for a **movie rental platform** called **Movie Mania */ const movies = [ - { title: "Fast & Furious 10", genre: "Action", rating: 7.5, rented: true }, - { title: "The Notebook", genre: "Drama", rating: 8.0, rented: false }, - { title: "Spider-Man: No Way Home", genre: "Action", rating: 8.7, rented: true }, - { title: "Superbad", genre: "Comedy", rating: 7.0, rented: false }, - { title: "The Dark Knight", genre: "Action", rating: 9.0, rented: true }, - { title: "The Intern", genre: "Comedy", rating: 7.4, rented: false } - ]; - - /* + { title: "Fast & Furious 10", genre: "Action", rating: 7.5, rented: true }, + { title: "The Notebook", genre: "Drama", rating: 8.0, rented: false }, + { + title: "Spider-Man: No Way Home", + genre: "Action", + rating: 8.7, + rented: true, + }, + { title: "Superbad", genre: "Comedy", rating: 7.0, rented: false }, + { title: "The Dark Knight", genre: "Action", rating: 9.0, rented: true }, + { title: "The Intern", genre: "Comedy", rating: 7.4, rented: false }, +]; + +/* Task 1: Movie Titles and Ratings 🎥 (`.map`) @@ -30,7 +34,7 @@ const movies = [ Steps: 1. Use `.map` to create a new array where each item is a string in this format: - "[title] - Rating: [rating]/10" + "[title] - Rating: [rating]/10 2. Log the resulting array. Expected Output: @@ -43,11 +47,15 @@ const movies = [ "The Intern - Rating: 7.4/10" ] */ - - // ✍️ Solve it here ✍️ - - - /* + +// ✍️ Solve it here ✍️ + +const moveTitleRating = movies.map((movie) => { + return `${movie.title},Rating:${movie.rating}/10`; +}); +console.log(moveTitleRating); + +/* Task 2: Find Highly Rated Movies 🌟 (`.filter`) Your customers have requested a list of **highly rated movies** @@ -64,8 +72,7 @@ const movies = [ { title: "The Dark Knight", genre: "Action", rating: 9.0, rented: true } ] */ - - // ✍️ Solve it here ✍️ - - \ No newline at end of file +// ✍️ Solve it here ✍️ +const moveRating = movies.filter((movie) => movie.rating > 8.0); +console.log(moveRating); diff --git a/dom_challenges.js b/dom_challenges.js index 1f414b8..39cfed2 100644 --- a/dom_challenges.js +++ b/dom_challenges.js @@ -156,35 +156,65 @@ export function displayArticles(category, featuredArticle = null) { // Use the provided featured article or default to the first one const article = featuredArticle || articles[0]; + + - // 1. Clear previous content + - // 2. Create container elements + // 1. Clear previous content +newsContainer.innerHTML=""; + // 2. Create container elements +const webMainDiv = document.createElement("div") + webMainDiv.className="featured-article" // 3. Create article element - +const webMainArticle=document.createElement("article") + webMainArticle.className="news-card featured" // 4. Create and setup image - +const webMainImage = document.createElement("image") + webMainImage.className=("news-image") + webMainImage.alt= articles.image + webMainImage.src= articles.image // 5. Create content container - +const webMaineDive =document.createElement("div") +webMaineDive.className=("news-content") // 6. Create featured label - + const webMainSpan =document.createElement("span") + webMainSpan.className=("featured-label") // 7. Create title - + const webMainTitle = document.createElement("title") + webMainTitle.className =("news-title") + webMainTitle.textContent = newsData.title // 8. Create date - + const webMainDate = document.createElement("data") + webMainData.className=("news-date") // 9. Create excerpt +const webMainExcerp = document.createElement("excerp") +webMainExcerp.textContent =newsData.excerpt + // 10. Create tag article - // 10. Create tag + const webSpanTag = DocumentTimeline.createElement("span") + webSpanTag .textContent=newsData.span - // 11. Assemble the elements + // 11. Assemble the element=s // 12. Append the article container to the news container -} +} + webMainDiv.append( webMainArticle) + webMainDiv.append(webMainImage) + + webMaineDive.append(webMainSpan) + webMaineDive.append(webMainTitle) + webMaineDive.append(webMainDate) + webMaineDive.append(webMainExcerp) + webMaineDive.append( webSpanTag) + + + // DO NOT CHANGE THIS document.addEventListener("DOMContentLoaded", () => { diff --git a/index.html b/index.html index 6a59a72..0c1fec8 100644 --- a/index.html +++ b/index.html @@ -106,6 +106,7 @@