Function with dynamic Arrays

I am a noob in node red and I've wrote this function node and it works fine, but I have not every time three arrays, sometimes 2, sometimes up to 15 arrays and in this case my function node dosent work. I know there is a way to count the arrays, but how to ?????
Can somebody help me and change this code???

type or paste code here

var elv0 =[0].elevation.feet;
var loc0 =[0].station.location;
var typ0 =[0].station.type;
var raw0 =[0].raw_text;

var elv1 =[1].elevation.feet;
var loc1 =[1].station.location;
var typ1 =[1].station.type;
var raw1 =[1].raw_text;

var elv2 =[2].elevation.feet;
var loc2 =[2].station.location;
var typ2 =[2].station.type;
var raw2 =[2].raw_text;

msg.payload ='<li>'+loc0 + '  '+typ0+' - Elev: '+elv0+' ft'+'<br>'+raw0+'<br>'+
             '<li>'+loc1 + '  '+typ1+' - Elev: '+elv1+' ft'+'<br>'+raw1+'<br>'+
             '<li>'+loc2 + '  '+typ2+' - Elev: '+elv2+' ft'+'<br>'+raw2+'<br>';

return msg;


const data =;
const result = => {
    var elv = e.elevation.feet;
    var loc = e.station.location;
    var typ = e.station.type;
    var raw = e.raw_text;
    return `<li>${loc}  ${typ} - Elev: ${elv} ft<br>${raw}<br>`
msg.payload = result
return msg;
1 Like

wow.... it works

thank you very much, I've been trying for three days....


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.