I have found following piece of code:
if ( selectedDataTypes && selectedDataTypes.length === 1 && selectedDataTypes[0].dataTypes.length === 1) {
this.dropdownName = selectedDataTypes[0].dataTypes[0].name;
} else if ( selectedDataTypes && (selectedDataTypes.length > 1 || selectedDataTypes[0]?.dataTypes.length > 1)) {
this.dropdownName = 'MULTIPLE SELECTION';
} else {
this.dropdownName = 'DATA TYPES';
}
Would there be a way in javascript to simplify this branching?
Aucun commentaire:
Enregistrer un commentaire