Skip to content
Open

done #47

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
4 changes: 4 additions & 0 deletions array_challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const movies = [
*/

// ✍️ Solve it here ✍️
const movieTitlesAndRatings = movies.map(movie => ` movie name: ${movie.title} - Rating: ${movie.rating}/10`);
console.log(movieTitlesAndRatings);


/*
Expand All @@ -66,6 +68,8 @@ const movies = [
*/

// ✍️ Solve it here ✍️
const highlyRatedMovies = movies.filter(movie => movie.rating >= 8.0);
console.log(highlyRatedMovies);



72 changes: 70 additions & 2 deletions dom_challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,36 +125,104 @@ export function displayArticles(category) {
const newsContainer = document.querySelector('#news-container');
const articles = newsData[category];

// 1. Clear previous content
// 1. Clear previous content
newsContainer.innerHTML = '';



// 2. Create container elements
const featuredArticle = document.createElement('div');
featuredArticle.classList.add('featured-article');


const item = articles[0];

// 3. Create article element
const articleElement = document.createElement('article');
articleElement.classList.add('news-card' ,'featured');



// 4. Create and setup image
const image = document.createElement('img');
image.src = item.image;
image.alt = item.title;
image.classList.add('news-image');


// 5. Create content container
const content = document.createElement('div');
content.classList.add('news-content');

// 6. Create featured label
const Label = document.createElement('span');
Label.classList.add('featured-label');
Label.textContent = 'Featured';

// 7. Create title

const title = document.createElement('h2');
title.classList.add('news-title');
title.textContent = item.title;
// 8. Create date
const data = document.createElement('div');
data.classList.add('news-date');
data.textContent = item.date;


// 9. Create excerpt
const excerpt = document.createElement('p');
excerpt.classList.add('news-excerpt');
excerpt.textContent = item.excerpt;

// 10. Create tag
const tag = document.createElement('span');
tag.classList.add('news-tag');
tag.textContent = item.tag;

// 11. Assemble the elements

content.appendChild(Label);
content.appendChild(title);
content.appendChild(data);
content.appendChild(excerpt);
content.appendChild(tag);


articleElement.appendChild(image);
articleElement.appendChild(content);

featuredArticle.appendChild(articleElement);

newsContainer.appendChild(featuredArticle);










newsContainer.insertBefore(featuredArticle, newsContainer.firstChild);
}

function createfooter(){
const footer = document.createElement('footer');
footer.classList.add('down-footer');

const footertext = document.createElement('p');
footertext.textContent = "© sowdo marwo dhowow";

footer.append(footertext);
document.body.append(footer);
}

// DO NOT CHANGE THIS
document.addEventListener('DOMContentLoaded', () => {
const defaultCategory = 'Latest News'; // Define the default category
displayArticles(defaultCategory); // Display articles for the default category
document.querySelector(`.nav-links a[data-category="${defaultCategory}"]`).classList.add('active'); // Set active class

createfooter();
});
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<script src="array_challenges.js"></script>
<header class="header">
<div class="header-content">
<div class="header-top">
Expand Down
7 changes: 7 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,11 @@
font-size: 0.875rem;
margin-top: 1rem;
font-weight: 500;
}
.down-footer {
background: #1e293b;
color: white;
padding: 10px;
margin-top: 50px;
text-align: center;
}