Help me with syntax JavaScript

** don’t see what the problem is.
Why don’t working function**

Please always provide code that is possible to debug without spending time retyping it - as in paste your code in the post or provide an online version

If you wrap the function in round parenthesis there is any change?
As in .onclick = ()
Or if you store first the function in a variable?

@Andrew2004 Without seeing all of your code (including HTML), we can not no for sure what the issue is.