Tell us what’s happening:
Build a Favorite Icon Trigger Help 7 and 8 is not passing
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<ul class="item-list">
<li>Book<span class="favorite-icon">♡</span></li>
<li >Pen<span class="favorite-icon">♡</span></li>
<li >Ruler<span class="favorite-icon">♡</span></li>
</ul>
</body>
</html>
/* file: styles.css */
/* file: script.js */
const spans = document.querySelectorAll(".favorite-icon");
spans.forEach((span) => {
span.addEventListener("click", () => {
if (span.classList.contains("filled")) {
span.classList.remove("filled");
span.innerHTML = "♡";
} else {
span.classList.add("filled");
span.innerHTML = "❤";
}
});
});
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Challenge Information:
Build a Favorite Icon Toggler - Build a Favorite Icon Toggler