diff --git a/array_challenges.js b/array_challenges.js index 3e3c564..98a5728 100644 --- a/array_challenges.js +++ b/array_challenges.js @@ -20,7 +20,6 @@ const movies = [ { 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`) @@ -43,9 +42,19 @@ const movies = [ "The Intern - Rating: 7.4/10" ] */ + //return `${movie.title} Rating: ${movie.rating}/10` // ✍️ Solve it here ✍️ + const moviesList = movies.map((movie)=>{ + + return `${movie.title} - Rating: ${movie.rating}/10`; + + }); + console.log(moviesList) + + + /* Task 2: Find Highly Rated Movies 🌟 (`.filter`) @@ -67,5 +76,9 @@ const movies = [ // ✍️ Solve it here ✍️ - +const highlyMovie = movies.filter((movie)=>{ + return movie.rating >= 8.0 +}) + +console.log(highlyMovie) \ No newline at end of file diff --git a/dom_challenges.js b/dom_challenges.js index 1f414b8..789f24b 100644 --- a/dom_challenges.js +++ b/dom_challenges.js @@ -158,31 +158,65 @@ export function displayArticles(category, featuredArticle = null) { const article = featuredArticle || articles[0]; // 1. Clear previous content - + newsContainer.innerHTML = ""; + // 2. Create container elements - + const featureArticles = document.createElement ("div") + featureArticles.className = "featured-article" // 3. Create article element + const articleElement = document.createElement ("article") + articleElement.className = "news-card featured" // 4. Create and setup image - + const imageMain = document.createElement ("img") + imageMain.className = "news-image" + imageMain.src = article.image || ""; +imageMain.alt = article.title || "News image"; // 5. Create content container + const contentContainer = document.createElement("div") + contentContainer.className = "news-content" + // 6. Create featured label + const featureLabell = document.createElement ("span") + featureLabell.textContent = "Featured Story" // 7. Create title + const newsTitle = document.createElement ("h2") + newsTitle.className = "news-title" + newsTitle.textContent = article.title // 8. Create date + const newsdata = document.createElement ("div") + newsdata.className = "news-date" + newsdata.textContent = article.date // 9. Create excerpt + const excerptMain = document.createElement ("p") + excerptMain.className = "news-excerpt" + excerptMain.textContent = article.excerpt // 10. Create tag - + const createTag = document.createElement("span") + createTag.className ="tag" + createTag.textContent = article.tag // 11. Assemble the elements - + contentContainer.appendChild(featureLabell) + contentContainer.appendChild( newsTitle) + contentContainer.appendChild (newsdata) + contentContainer.append(excerptMain) + contentContainer.appendChild(createTag) + + featureArticles.appendChild(articleElement) + featureArticles.appendChild(imageMain) + + // 12. Append the article container to the news container + newsContainer.appendChild(featureArticles) + } @@ -193,4 +227,6 @@ document.addEventListener("DOMContentLoaded", () => { document .querySelector(`.nav-links a[data-category="${defaultCategory}"]`) .classList.add("active"); // Set active class + + }); diff --git a/index array.html b/index array.html new file mode 100644 index 0000000..a305052 --- /dev/null +++ b/index array.html @@ -0,0 +1,12 @@ + + + + + + Document + + +
ADVANCE ARRAY
+ + + \ No newline at end of file