'Unable to check all 3 conditions and return them in JS
I have a method that checks a con variable as true or false and return a device tag for each device, I could only get the first tag even though the 2nd, 3rd condition is true. How to check all the conditions and return all the devices.
function populateDevices(){
if(ethsrc[0].con === true) {
return ethsrc
.filter(i => i.srcid === 0)
.map((i,idx) => (
<Device name={i.name} srcid={i.srcid} inst={idx} drt={i.drt} data={i.data} />
))
}
if(ebmcard[0].con === true){
return ebmcard
.filter(i => i.srcid === 0)
.map((i,idx) => (
<Device name={i.name} srcid={i.srcid} inst={idx} drt={i.drt} data={i.data} />
))
}
if(mi5module[0].con === true){
return mi5module
.filter(i => i.srcid === 0)
.map((i,idx) => (
<Device name={i.name} srcid={i.srcid} inst={idx} drt={i.drt} data={i.data} />
))
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
