Hello, I'm trying to have a dynamic number of returns depending on a variable, I did this but it's only handling up to length 6, and sometimes there's up to 20. I'd like to know a proper way to do it !
Thanks
/////////////////////////// Send DATA ///////////////////////////
if (msg.payload.hotspots.length == 2) return [[hotspotInfluxDB(0), msgInfluxDB(0), hotspotInfluxDB(1), msgInfluxDB(1)], msgTelegram]
else if (msg.payload.hotspots.length == 3) return [[hotspotInfluxDB(0), msgInfluxDB(0), hotspotInfluxDB(1), msgInfluxDB(1), hotspotInfluxDB(2), msgInfluxDB(2)], msgTelegram]
else if (msg.payload.hotspots.length == 4) return [[hotspotInfluxDB(0), msgInfluxDB(0), hotspotInfluxDB(1), msgInfluxDB(1), hotspotInfluxDB(2), msgInfluxDB(2), hotspotInfluxDB(3), msgInfluxDB(3)], msgTelegram]
else if (msg.payload.hotspots.length == 5) return [[hotspotInfluxDB(0), msgInfluxDB(0), hotspotInfluxDB(1), msgInfluxDB(1), hotspotInfluxDB(2), msgInfluxDB(2), hotspotInfluxDB(3), msgInfluxDB(3), hotspotInfluxDB(4), msgInfluxDB(4)], msgTelegram]
else if (msg.payload.hotspots.length == 6) return [[hotspotInfluxDB(0), msgInfluxDB(0), hotspotInfluxDB(1), msgInfluxDB(1), hotspotInfluxDB(2), msgInfluxDB(2), hotspotInfluxDB(3), msgInfluxDB(3), hotspotInfluxDB(4), msgInfluxDB(4), hotspotInfluxDB(5), msgInfluxDB(5)], msgTelegram]
else return [[hotspotInfluxDB(0), msgInfluxDB(0)], msgTelegram]