0
What happend if I didn't use break in switch's case?
2 Answers
0
If you don't use break then all the cases will executes until the next break statement found
0
to add to the previous answer if u dont add break at all it would use the default e.g
switch (myVar) {
case ("hi") :
document.write("hi to you too");
/*no break here*/
case("hello"):
document.write("hello to u too");
/*no break here either*/
default:
document.write("bye");
}
and say myVar is hi or hello, itd display bye as ther are no breaks.
I hope i helped