Error when making a class.p5js

Im trying to make a class but I’m getting and error:

1: Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode

"%cDid you just try to use p5.js’s str() function? If so, you may want to move it into your sketch’s setup() function.

Im wondering what I’m doing wrong.

20

Hi @ricodevs – I do see the word “let” in line 1 of your code screenshot, and the word “let” in your error message… but I defer to people experienced with the p5js editor.

In the future, please don’t just post screenshots to the forum – cut and paste your actual code so that people have the option to actually run it when trying to help you.

You can add the code to your original post with the edit button, then format it with highlight + “</>” button.

Could you post your entire code?

I am really new to this, and this was my first post. The problem was that I got an error message after coping a sketch from the web editor to the editor. It worked fine in the web editor but after moving it, I got the error message. I tried to copy a sketch from coding train and got the same problem. Maybe there is some problem with my setup.

I have deleted the code, but I will contact the forum if I get the same problem again, with the complete code posted in it:)

1 Like