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
17 changes: 15 additions & 2 deletions array_challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -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`)
Expand All @@ -67,5 +76,9 @@ const movies = [

// ✍️ Solve it here ✍️


const highlyMovie = movies.filter((movie)=>{
return movie.rating >= 8.0
})

console.log(highlyMovie)

46 changes: 41 additions & 5 deletions dom_challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)


}

Expand All @@ -193,4 +227,6 @@ document.addEventListener("DOMContentLoaded", () => {
document
.querySelector(`.nav-links a[data-category="${defaultCategory}"]`)
.classList.add("active"); // Set active class


});
12 changes: 12 additions & 0 deletions index array.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h5>ADVANCE ARRAY</h5>
<script src="array_challenges.js"></script>
</body>
</html>