Dominique Ari
Dominique Ari
2,721 Points

Would it not be better to use classList.add?

wouldn't it be better to use these instead? In practice you wouldn't normally want to overwrite all existing classes.'highlight');'highlight');

1 Answer

Robert Manolis
Robert Manolis
Treehouse Guest Teacher

Hi Dominique Ari, you're absolutely correct. While setting a className with a simple assignment operator, =, is something to be aware of, the safer approach is to use the classList property along with its add() or remove() or toggle() methods, as you mentioned, and for the very reason you mentioned. :thumbsup: