Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrian Ball
Treehouse Project ReviewerThe console will output the message "I'm being removed":
I don't fully understand what this code is reads.
Will the output message post if the button remove is clicked?
2 Answers
Steven Parker
231,269 PointsI believe this is the code you are referring to:
card.addEventListener('click', (e) => {
if (e.target.tagName === 'BUTTON') {
if (e.target.textContent === 'remove') {
console.log("I'm being removed");
}
}
});
The important thing to notice here is that the log statement is nested inside two "if" statements. So it will only run when both of the conditions is true. The first one is testing if the clicked item is a button, and the second one tests if the text on the button says "remove".
Brian Ball
Treehouse Project ReviewerRight, Originally I read the code incorrectly but was only confused by the structure of how the if statements are written. Thanks for the help Steven!