0

Why is not working this switch with OR

var cedula = 00; switch (cedula) {   case 99 || 00:     document.write("Debe presentar su declaraci�n de renta a mas tardar el 9 de Agosto");     break;   case 97 || 98:     document.write("Debe presentar su declaraci�n de renta a mas tardar el 10 de Agosto");     break;   case 95 || 96:     document.write("Debe presentar su declaraci�n de renta a mas tardar el 11 de Agosto");     break; case 93 || 94:     document.write("Debe presentar su declaraci�n de renta a mas tardar el 14 de Agosto");

3rd Aug 2017, 2:30 PM
Andres Restrepo
Andres Restrepo - avatar
4 ответов
+ 2
LoLLLLLLLLL It seem that You misunderstand!!! You think that 99||00 is 0???? Absolutely NOT! 99||00 = 99 and 99&&00 = 0 93||94 = 93 (no 94 in there) What should I say ha???? You misunderstand what the switch does! If you want truly to do "or" with the switch. code would be like case 99:case 0:... switch just compare cedula and case that It's equal or not. If equal just jump to that and then execute else jump to another
3rd Aug 2017, 3:39 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 1
cedula = 0 while all cases doesn't have condition with 0 value
3rd Aug 2017, 3:00 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
0
That is not the problem the case is there 00
3rd Aug 2017, 3:24 PM
Andres Restrepo
Andres Restrepo - avatar
0
Thanks for your answer
3rd Aug 2017, 3:45 PM
Andres Restrepo
Andres Restrepo - avatar