Javascript Add and Remove Class On Scroll

You can just add an else clause to your existing event listener and call classList.remove

window.addEventListener('scroll', function() {
  var elementTarget = document.querySelector('.section-2');
  if (window.scrollY > (elementTarget.offsetTop + elementTarget.offsetHeight)) {
      document.querySelector('.section-3').classList.add('anotherclass');
  } else {
      document.querySelector('.section-3').classList.remove('anotherclass');
  }
});
window.addEventListener('scroll', function() {
      if (window.scrollY > 100) {
        document
          .querySelector('.section-3')
          .classList.remove('sticky-invisible');
        document
          .querySelector('.section-3')
          .classList.add('sticky-visible');
      } else {
        document
          .querySelector('.section-3')
          .classList.remove('sticky-visible');
        document
          .querySelector('.section-3')
          .classList.add('sticky-invisible');
      }
    });