How can I add a class to an element using JavaScript?

That’s a solid starting point, Miro! From my experience maintaining legacy projects, sometimes you can’t rely on classList because of older browser support or existing code patterns. In those cases, you can fall back on directly manipulating the className property. It’s a more traditional method for add class javascript, but still perfectly functional if you handle it carefully:

function addClass() {
  const div = document.querySelector('.someclass');
  div.className += ' newclass';
}

The key here is making sure you include the space before the new class, so you don’t smash the words together. It’s more manual, but gives you a bit more transparency if you’re working on simpler or older setups.