Assessment needed for Events 3 skill test

Hi,

I have written code that changes the color of the buttons when clicked to the color contained in the button’s data-color attribute… Please provide suggestions to improve this code.

Link-https://codepen.io/ILAroy-611/pen/xxyqBZr?editors=0010

Thanks,
ila

Hi @ILA_Saxena and welcome to the community :wave:

Nice work!
I have two remarks:

  • The task asks to change the color of the button-bar (the element around the buttons) not the buttons themselves. Do you know how you could achieve that?
  • While it works to use innerText to get the color, it feels a bit brittle. In real projects texts tend to change over time, which would break your code. You could use the data-color attribute for that. There’s a nice way to access data-* attributes: dataset.

Feel free to ask questions if something isn’t clear. :slightly_smiling_face:

See you,
Michael