Error - arrow function not defined, really?

Screen Shot 2020-10-14 at 11.04.21 PM

The error hover test says "getRGB is not defined. But, you define them without const or let or whatever…

What am I missing?

Are you getting any errors in dev tools or in the logs (in other words, is it just an issue with the editor but not your code?)

That’s actually a limitation of CodeMirror’s linting. When you define a variable in Javascript without a keyword before it like var or let or const, the variable becomes a global variable, although it is not recommended to do so because it could accidentally overwrite existing global variables. CodeMirror doesn’t know about global variable declarations, and hence, it throws a linting error saying the variable is not defined. You can however ignore the editor’s warning and your code will execute as normal.

This issue has been discussed on this forum before, if you do a search for “global variables”, the first few threads will be about this same topic.

There is a workaround which you can do if you do not have too many global variables. You can add a multi line comment at the top of your file and the warning will disappear.

For example:

/* global whoIsTheCoolestAvenger */ 

// doing the above will make the
// editor warning disappear

whoIsTheCoolestAvenger = "spiderman"

Hope this helps!


Wow, I didn’t know comments could have actual functions! Thanks for the tips.

@RiversideRocks the code formatter still works and there aren’t any errors in the log - it’s just a little annoying.


This is why most coding editors suck like glitch This is why glitch should use Ace.js again…


I’m surprised about that comment about Ace.js coming from you. From a previous discussion in the GlitchyPastePen forum, (even @CarlyRaeJepsenStan was present in that discussion) you said that Ace.js sucks and CodeMirror is better. :stuck_out_tongue_winking_eye:


No it was the other way around…

I said CodeMirror sucked, and Ace.js was better because it is way to easy to mess with than CodeMirror.

I just made a pure mistake by @RiversideRocks saying I should use codemirror

And Monaco looks very nice!

1 Like

Yeah, but really hard to setup.

Alternatively, there’s Theia, which uses less space, has more features and is the closest thing that looks like Monaco.

1 Like

I don’t know how to make my own gitpod :man_facepalming: