0
What wrong with this code? It can't output
<html> <head> </head> <body> <script> var girl = 1; switch (girl) { case 2; alert("she is a child "); break; case 1; alert("she is too small"); break; default; document.write("sorry we can't help you"); } </script> </body> </html>
2 Answers
+ 10
your case statements have a semicolon instead of colon. change them to colon.
case 2: <= correct
case 2; <= wrong
What wrong with this code? It can't output
<html>
<head>
</head>
<body>
<script>
var girl = 1;
switch (girl) {
case 2:
alert("she is a child ");
break;
case 1:
alert("she is too small");
break;
default:
document.write("sorry we can't help you");
}
</script>
</body>
</html>
+ 1
thanks