jeudi 21 novembre 2019

Simplify if statement - Angular

Is there a way to simplify this If statement? All variables are strings and I reuse them in both but depending if it returns true or false.

if(params.province && !params.streetType && !params.streetNr){
  this.localityIdCP = params.localityId;
}

if(params.province && params.streetType && !params.streetNr){
  this.streetIdCP = params.localityId;
}

Aucun commentaire:

Enregistrer un commentaire