Test Your Skills: Events 3 Feedback

Hi everyone!!! I completed the last task of this problems and need feedback, is it correct this way? What could I have done better?, thanks for the time :wink: .

1 Like

Hi @Matias_Concha :wave:

Your code works correctly. Unfortunately you missed one requirement of the task:

you need to set an event listener on the <button> s’ parent element

The idea of this task is to only have one event listener on the button bar. Something like this:

function setColor(e) {
  /* You can achieve the goal with one line of code in here */

buttonBar.addEventListener('click', setColor);

This concept is called event delegation. To get an idea what to do, have a look at the example on this page:

For another example I recommend this article from David Walsh:

Do you get the idea? Feel free to ask again if you need more help. :slightly_smiling_face:

Happy Coding!

1 Like

Hi @mikoMK, you’re right i have to refactor my code, thanks for the info :smiley: .

1 Like