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
47 changes: 27 additions & 20 deletions array_challenges.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*

The Dataset: Movie Mania
Expand All @@ -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`)

Expand All @@ -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:
Expand All @@ -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**
Expand All @@ -64,8 +72,7 @@ const movies = [
{ title: "The Dark Knight", genre: "Action", rating: 9.0, rented: true }
]
*/

// ✍️ Solve it here ✍️



// ✍️ Solve it here ✍️
const moveRating = movies.filter((movie) => movie.rating > 8.0);
console.log(moveRating);
52 changes: 41 additions & 11 deletions dom_challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ <h2 class="news-title">Apple Unveils Revolutionary Mixed Reality Device</h2>
</div>
</article>
</div>
<script src="array_challenges.js"></script>
</body>

</html>