Skip to content

Commit

Permalink
perfect work
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelo Silveira committed Jul 17, 2024
1 parent 88d960c commit f416f27
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
const allCoursesContainer = document.querySelector('#individual-nanodegree-programs');

function createCardWithButton() {
const cardDiv = document.createElement('div');
cardDiv.className = 'card--nanodegree__favorites';

const button = document.createElement('button');
button.className = 'button--primary';
button.textContent = 'Add to favorites';

cardDiv.appendChild(button);

return cardDiv;
}

function createCardWithStars() {
const cardDiv = document.createElement('div');
cardDiv.className = 'card--nanodegree__3stars';

const starsDiv = document.createElement('div');
starsDiv.className = 'three-stars hide-stars';
starsDiv.textContent = '🌟 🌟 🌟';

cardDiv.appendChild(starsDiv);

return cardDiv;
}

//const document.body.appendChild(cardElement);

const cardContainers = allCoursesContainer.querySelectorAll('.card__container');
//console.log(cardContainers[1].querySelector('.card--nanodegree__title'));

cardContainers.forEach(function(value) {
const cardTitle = value.querySelector('.card--nanodegree__title');
const cardFavoriteBtn = createCardWithButton();
cardTitle.insertAdjacentElement('afterend',cardFavoriteBtn);
const cardWithStars = createCardWithStars();
cardFavoriteBtn.insertAdjacentElement('afterend',cardWithStars);
})

function changeText(btn) {
const btnText = btn.textContent;
if(btnText==='Add to favorites'){
Expand Down

0 comments on commit f416f27

Please sign in to comment.