Hello,
I'm a totally newby with node-red (and javaScript). I'm receiving an array and would like to look for an entry with two specific values. It these values match, set a variable to 1 (to grant access and open the door) and terminate the loop. I have tried with the following function node, but it complains because there is an 'Error in JavaScript code'
let access=0;
for (i = 0; i < msg.payload.length; i=i+1)
if(msg.payload[i].clients[0].idColegiat = "3554" && payload[i].idSala = "3") {
access = 1;
i = msg.payload.length;
}
msg.payload = authorize;
return msg;
Any hint or advise would be really appreciated. Thanks!!
I think it's fair to say that @alebaca managed to pack quite a few beginners' mistakes into a few lines of javascript, none of us managed to spot all of them.
Still, everyone is a beginner sometime, I hope Alejandro is not too discouraged by this experience