HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p>If there is no break statement then the cases following the matched case including default will get executed..</p> <p>In this example successive case is "case 1:", so "case 2:" and "default:" will also be executed.</p> <p id="point"></p> <script> var x = document.getElementById("point"); var num = 1; var txt = ""; switch(num){ case 0: txt += "zero"; case 1: txt += "One"; case 2: txt += "Two"; default: txt += "None of these"; } x.innerHTML = txt; </script> </body> </html>
OUTPUT
×

Save as Private