However, they will show you errors in the editor since the default level of checking was set to help users who are typically not programmers. i.e. it lets you know you have missed a const/let
In your case, you are simply missing a let (e.g. let receivers='';) will fix this one. NOTE: it is good practice to declare variables properly as it helps avoid bugs.
If you must revert to the old editor and keep your bad code, then you can switch from monaco to ace (for now - will be depreciated in the next node-red version). The setting for the code editor can be found in your settings.js file
I used your mantra and have a question...
why cant i use the let statement in de for.... loop on lines 19 and 20: let jsontmp= and let teken =
const sel = msg.payload.selected;
const nwvar = "Geen opties";
if (sel === nwvar) {
const json = "<empty>"
msg.json = json;
msg.oms3 = sel;
msg.payload = sel // deze waarde hebben andere list nodes nodig om te bepalen wat aan/uit
msg.device = sel; //extra
flow.set("json", json);
flow.set("device", sel); //sel
}
else {
const nwobj = msg.payload.output[msg.payload.selected]
let teken = "";
let jsontmp = "";
let i = 0;
for (i = 0; i < nwobj.length; i++) {
jsontmp = jsontmp + teken + JSON.stringify(nwobj[i]);
teken = ",";
}
let json = "[" + jsontmp + "]";
msg.json = json;
msg.oms3 = sel;
msg.payload = sel // deze waarde hebben andere list nodes nodig om te bepalen wat aan/uit
msg.device = sel; //extra
flow.set("json", json);
flow.set("device", sel); //sel
}
return msg;
To clarify, there ARE some occasions where var is valid and might be used. Just not too many. It is helpful to understand what var actually does as it is more complex than it seems. Avoid in general use but worth learning for that odd occasion where it makes your code simpler.