10th Sep 2022, 8:27 AM
Kumar Anshuman
5 Answers
+ 3
If you don't use break then all case will be execute till the next break after the matched case
10th Sep 2022, 8:35 AM
A͢J
A͢J - avatar
+ 2
You have to read again how switch works and in addition think, what happend when as in your example, will don‘t use a statement break.
10th Sep 2022, 8:37 AM
JaScript
JaScript - avatar
+ 2
Kumar Anshuman But case = 10 matched and there is no break in all next cases so all cases will be execute. https://code.sololearn.com/cXYNRaL1de4A/?ref=app
10th Sep 2022, 8:47 AM
A͢J
A͢J - avatar
+ 1
A͢J case = 30 does not match then how does it execute?
10th Sep 2022, 8:38 AM
Kumar Anshuman
+ 1
JaScript Oh yes! I got it. As case = 10 is found to be correct , it will execute all the following statements even if the rest of the cases are correct or incorrect.
10th Sep 2022, 8:48 AM
Kumar Anshuman