jeudi 29 octobre 2020

Multiple IF conditions inside filter

I want to filter a table (2d array) together with IF condition (depending on HTML select value) and use this code

transportRegFiltered = transportReg.filter(r => 
          {if(lugarDe.value == "TODOS"){return true} else {return (r[6] == lugarDe.value)}    
          })

with 1 condition it works but I need to have several ones. Smth like

transportRegFiltered = transportReg.filter(r => 
          {if(lugarDe.value == "TODOS"){return true} else {return (r[6] == lugarDe.value)} 
           if(lugarA.value == "TODOS"){return true} else {return (r[7] == lugarA.value)}
          }

How can I do it?

Aucun commentaire:

Enregistrer un commentaire