Node-RED Java Script (checker)

Hi There,
while I use Node Red I get on each “deploy” hints that some Nodes not configured correctly.

Try to correct the java skipts but I cant see the hints, as they as smal as a post stamp.
Not managed to enlarge the view… Hints welcome?
Kind regards CyberHome

Using Chrome (latest) but same problem on Firefox

Copy past the code to an online code checker.

Is ‘===’ correct? Should it be 2 instead of 3?

1 Like

You need to declare your variables with ‘const’ or ‘var’ or ‘let’. It will still work without doing that but will show an error.

1 Like

Thank you, I did this already, the “external checker” found on of the four failtures (interpretation of the red marks). It was the const declaration as @nickgeorge333 detected as well. No idea what the other “red marks” are about.

No idea how to enlarge this smal window (at least is this my problem also or is it working well on your Node-RED) please?

Regards CyberHome

My impression is that this ‘window’ has always been that size and is just an overview indicator of the entire (could be very long) code, showing where the errors are in relation to the entire code block.
Useful only for very long scripts where you want to identify and scroll to an error quickly, and I believe therefore that this is not a fault.

The error messages do pop up on their own when hovering over the bits marked with red lines. Also try ‘alt’ F8 - works rather well I think.

And, while we are on the subject, I suggest not using ‘var’ but rather ‘let’ or ‘const’ as var can lead to memory leaks. Also, you could avoid using any variables at all since you are just doing a simple predicate test. The following works for me.

msg.payload = msg.payload === '0' ? 'close' : 'open'

Dear @Biscuit
thank you for your fast support.

  • Changed my “var” defintion as proposed to “const”
    Anyhow switched the function ot a switch followed by functions (simple workarround) and will try to get it back to simple function
  • F8 works well ! THANK YOU

Wish you a nice day
Cyberhome