Is there a way to use the destructuring feature in switch ... case statement instead of using nested if else statements ??
For example I would expect something like this :
const tall = true;
const clean = true;
switch ([tall, clean]) {
case [true,true]:
console.log("Perfect");
break;
case [false,true]:
console.log("Ok");
break;
case [true,false]:
console.log("Not so good");
break;
default:
console.log("Terrible");
}
instead of using :
if (tall){
if (clean){
...
}else{
...
}
}else{
if (clean){
...
}else{
...
}
}
Aucun commentaire:
Enregistrer un commentaire