Hi All,
I'm trying to create a function to concatenate array data with various conditions. But the result is not what I expected. I've tried issuing node.warn on the variable that outputs several conditions, but there is the following error:
Here is the code that I use:
var a = msg.payload[0]; //date
var b = Number(msg.payload[1])/1; //count
var c = msg.payload[2]; //load
var c2={} ;
if ( b < 10){
c2 = c * 2 ;
return c2;
} else if ( 10 < b < 20)
{
c2 = c *1.5;
return c2;
} else if ( 20 < b < 30)
{
c2 = c*1.2;
return c2;
} else {
c2 = c;
return c2;
}
node.warn("c2");
var d = msg.payload[3];
var e = msg.payload[4];
var f = msg.payload[5];
var g = msg.payload[6];
const SENSORS=[a,b,c2,d,e,f,g];
msg.payload=SENSORS;
return msg;
Maybe some of you can help me. I really appreciate your help in advance. Thank You