When I remove that first line in the if statement it works.
header.classList.add('go');
header isn't defined anywhere in the code so it's breaking there. If you were trying to get the header element you should use document.querySelector('header') but based on the rest of your code I'm not seeing any purpose for that so I'd just remove the line.
Will note this only works in-page and not in the module preview since we're unable to activate a scroll event when in module preview.
If this answer solved your question, please mark it as the solution.
When I remove that first line in the if statement it works.
header.classList.add('go');
header isn't defined anywhere in the code so it's breaking there. If you were trying to get the header element you should use document.querySelector('header') but based on the rest of your code I'm not seeing any purpose for that so I'd just remove the line.
Will note this only works in-page and not in the module preview since we're unable to activate a scroll event when in module preview.
If this answer solved your question, please mark it as the solution.