3
I wonder if there’s any way to simplify this code... in the example 1 to 7 I want the same result but so far are few but... and if there were many numbers would have like not to have to put so many cases or it would be better to use if same?
let codigo = 7;
switch(codigo){
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
console.log("Acertou");
break;
case 8:
console.log("Poderia ser mas... não é.");
break;
default:
console.log("Tente mais tarde");
break;
}
It has how to simplify this code !!! even has, in this context a
if
in my opinion is better, now if it is many ... usually the code has something that we do not know, maybe with comparison.– novic
I do with pathern test of regex, it gets very small
– flourigh