From 0177f4843f289a167179ae5638ebd2898a272bd0 Mon Sep 17 00:00:00 2001 From: Sundus Hussein Date: Fri, 12 Dec 2025 13:09:50 -0800 Subject: [PATCH] Completed Week 6 assignment tasks --- .DS_Store | Bin 0 -> 6148 bytes array_challenges.js | 20 ++++++++++++-- dom_challenges.js | 66 ++++++++++++++++++++++++++++++-------------- htmlstructure.html | 32 +++++++++++++-------- 4 files changed, 83 insertions(+), 35 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0400c967c4b90be1ba3489c298f74103d4edb24c GIT binary patch literal 6148 zcmeHKOHRWu5PdEcYJo+84I8AaSw!Lnp-LAl*uVjxKME*NsZE8t%K^r{cy@`-=UCzvLp-35Y;CkT zwvho@yJN1`jK4n0>z84S7ffj9i1CE^Wi}lSvgv>kvRy8y@uwHIfJ2Nh#dB!~{FdRP zmf?Wa`WWDmb;o%1btmlIS1Y^ITHFzLT+YfFBXZ7T!9AGM&X^_sepbuz#vEs*f8WM6 zdYn^=D`L!SqiRHBQmeY>t1Veo85**`iKF*Y6{avT28;n?U<(-FnJv=VS2Sx37z4(@ ziUD~)L{z~fV4>(=9W?$5Ky1?Og>Csbl$a=B60lI@6N=MNqK3L~#c&!_foQV8$5uQwF{Oh2?2& literal 0 HcmV?d00001 diff --git a/array_challenges.js b/array_challenges.js index 3e3c564..9a9698c 100644 --- a/array_challenges.js +++ b/array_challenges.js @@ -29,8 +29,8 @@ const movies = [ for a promotional email campaign. Steps: - 1. Use `.map` to create a new array where each item is a string in this format: - "[title] - Rating: [rating]/10" + 1. Use `.map` to create a new array where each item is a in this format: + "[title] - Rating: [rating]/10"string 2. Log the resulting array. Expected Output: @@ -46,7 +46,14 @@ const movies = [ // ✍️ Solve it here ✍️ + /* const title = movies.map((data) => { + return data.title + }) + + console.log(title) + */ + /* Task 2: Find Highly Rated Movies 🌟 (`.filter`) @@ -66,6 +73,13 @@ const movies = [ */ // ✍️ Solve it here ✍️ + + /* const HighlyRatedmovies = movies.filter((data) => { + if(data.rating >= 8){ + return data.title + } + }) - \ No newline at end of file + console.log(HighlyRatedmovies) + */ \ No newline at end of file diff --git a/dom_challenges.js b/dom_challenges.js index 1f414b8..0771a90 100644 --- a/dom_challenges.js +++ b/dom_challenges.js @@ -133,7 +133,7 @@ export const newsData = { }; // html structure -{ + /*
*/ -} // YOUR TASK: Complete this function using the html structure in the htmlstructure.html file -export function displayArticles(category, featuredArticle = null) { +export function displayArticles(category, featuredArticle = null){ const newsContainer = document.querySelector("#news-container"); const articles = newsData[category]; - - // Use the provided featured article or default to the first one + // Use the provided featured arrticle or default to the first one const article = featuredArticle || articles[0]; - // 1. Clear previous content +const newsGrid = document.querySelectorAll('.news-grid')[1] +console.log("newsGrid:", newsGrid) +// 1. Clear previous content + newsGrid.innerHTML = "" // 2. Create container elements - - + const newsGridMainDiv = document.createElement("div") + newsGridMainDiv.className = "featured-article" // 3. Create article element - + const articleElement = document.createElement("article") + articleElement.className = ("news-card featured") // 4. Create and setup image - + const newsimage = document.createElement("img") + newsimage.className = "news-image" + newsimage.alt = article.title + newsimage.src = article.image // 5. Create content container - + const newsContent = document.createElement("div") + newsContent.className = "news-conten" // 6. Create featured label - + const newsFeature = document.createElement("span") + newsFeature.className = "featured-label" + newsFeature.textContent = "Featured Story" // 7. Create title - + const newsTitle = document.createElement("h2") + newsTitle.className = "news-title" + newsTitle.textContent = article.title // 8. Create date - + const newsDate = document.createElement("div") + newsDate.className = "news-date" + newsDate.textContent = article.date // 9. Create excerpt - + const newsExcerpt = document.createElement("p") + newsExcerpt.className = "news-excerpt" + newsExcerpt.textContent = article.excerpt // 10. Create tag - - + const newsTag = document.createElement("span") + newsTag.className = "tag" + newsTag.textContent = article.tag // 11. Assemble the elements - + newsGridMainDiv.append(articleElement) + newsGridMainDiv.append(newsContent) - // 12. Append the article container to the news container - -} + articleElement.append(newsimage) + newsContent.append(newsFeature) + newsContent.append(newsTitle) + newsContent.append(newsDate) + newsContent.append(newsExcerpt) + newsContent.append(newsTag) + // 12. Append the article container to the news container + newsGrid.append(newsGridMainDiv) + return articles +} // DO NOT CHANGE THIS document.addEventListener("DOMContentLoaded", () => { const defaultCategory = "Latest News"; // Define the default category @@ -194,3 +217,4 @@ document.addEventListener("DOMContentLoaded", () => { .querySelector(`.nav-links a[data-category="${defaultCategory}"]`) .classList.add("active"); // Set active class }); + diff --git a/htmlstructure.html b/htmlstructure.html index ff721c2..cee4056 100644 --- a/htmlstructure.html +++ b/htmlstructure.html @@ -1,12 +1,22 @@
- -
\ No newline at end of file + +