Testing Javascript with an error

I have tested interesting source code at the following URL:
https://codepen.io/designcourse

var checkbox = document.querySelector('input[name=theme]');

checkbox.addEventListener('change', function()
 {
  if(this.checked) {
   trans()
   document.documentElement.setAttribute('data-theme', 'dark')
  } else {
   trans()
   document.documentElement.setAttribute('data-theme', 'light')
  }
 }
)

let trans = () => {
 document.documentElement.classList.add('transition');
 window.setTimeout(() =>
  {
   document.documentElement.classList.remove('transition')
  }, 1000
 )
}

It is an error: SyntaxError: missing ; before statement
What should be done to fix ; before statement
Need help.

Hello @toplisek. The link you have given is for a set of pens, not an individual pen. You’ll need to say which of that set of pens you are having trouble with.

I found it, at https://codepen.io/designcourse/pen/OGVZjr

The error you mentioned doesn’t happen at that codePen page. Can you give us more details about what you’ve done so that we can experience and understand more about when the problem is happening.

See source file and export inside ZIP.

Do you refer to the zip from the export section of this codepen page?

yes, this is the correct source and nice example.

Somehow I am failing to get the error that you mention. I have Chrome, Firefox, and Edge on a desktop system available to me.

Can you please direct me as to how I should adjust my environment so that I may experience the same syntax error that you are having.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.