Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion array_challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ const movies = [

// ✍️ Solve it here ✍️


const moviesTitles = movies.map ( movie => {
return ` ${movie.title} - Rating: ${movie.rating}/10`
})
console.log(moviesTitles)




/*
Task 2: Find Highly Rated Movies 🌟 (`.filter`)

Expand All @@ -68,4 +75,7 @@ const movies = [
// ✍️ Solve it here ✍️


const highlyRated = movies.filter(movie => movie.rating >= 8.0);
console.log(highlyRated)


46 changes: 36 additions & 10 deletions dom_challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,31 +158,57 @@ export function displayArticles(category, featuredArticle = null) {
const article = featuredArticle || articles[0];

// 1. Clear previous content

newsContainer.innerHTML ="";
// 2. Create container elements

const featuredDiv = document.createElement("div");
featuredDiv.classList.add("featured-article");

// 3. Create article element

const articleCard = document.createElement("article");
articleCard.classList.add("news-card", "featured");
// 4. Create and setup image

const img = document.createElement("img");
img.classList.add("news-image");
img.src = article.image;
img.alt = article.title;
// 5. Create content container

const contentDiv = document.createElement("div");
contentDiv.classList.add("news-content");
// 6. Create featured label

const featuredLabel = document.createElement("span");
featuredLabel.classList.add("featured-label");
featuredLabel.textContent = "Featured Story";
// 7. Create title

const titleEl = document.createElement("h2");
titleEl.classList.add("news-title");
titleEl.textContent = article.title;
// 8. Create date
const dateEl = document.createElement("div");
dateEl.classList.add("news-date");
dateEl.textContent = article.date;

// 9. Create excerpt

const excerptEl = document.createElement("p");
excerptEl.classList.add("news-excerpt");
excerptEl.textContent = article.excerpt;
// 10. Create tag

const tagEl = document.createElement("span");
tagEl.classList.add("tag");
tagEl.textContent = article.tag;

// 11. Assemble the elements

contentDiv.appendChild(featuredLabel);
contentDiv.appendChild(titleEl);
contentDiv.appendChild(dateEl);
contentDiv.appendChild(excerptEl);
contentDiv.appendChild(tagEl);

articleCard.appendChild(img);
articleCard.appendChild(contentDiv);
featuredDiv.appendChild(articleCard);

// 12. Append the article container to the news container
newsContainer.appendChild(featuredDiv);

}

Expand Down
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ <h2 class="news-title">Apple Unveils Revolutionary Mixed Reality Device</h2>
</div>
</article>
</div>

<script src="array_challenges.js"></script>
<script src="dom_challenges.js"></script>


</body>

</html>