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>

27th Dec 2017, 1:00 AM
Chessbox
Chessbox - avatar
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>
27th Dec 2017, 1:03 AM
Lord Krishna
Lord Krishna - avatar
+ 1
thanks
27th Dec 2017, 1:07 AM
Chessbox
Chessbox - avatar