Home
<!DOCTYPE html> <html> <body> <h1>Demo: switch with string type</h1> <script> var str = "bill"; switch (str) { case "steve": alert("This is Steve"); case "bill": alert("This is Bill"); break; case "john": alert("This is John"); break; default: alert("Unknown Person"); break; } </script> </body> </html>
Result: