pouria.zareie@gmail.com Posted June 3, 2020 Share Posted June 3, 2020 <!-- error in code var x = "0"; --> <!DOCTYPE html> <html> <body> <h2>JavaScript switch</h2> <p id="demo"></p> <script> var x = "0"; switch (x) { case 0: text = "Off"; break; case 1: text = "On"; break; default: text = "No value found"; } document.getElementById("demo").innerHTML = text; </script> </body> </html> <!-- this is true code var x = 0; --> <!DOCTYPE html> <html> <body> <h2>JavaScript switch</h2> <p id="demo"></p> <script> var x =0; switch (x) { case 0: text = "Off"; break; case 1: text = "On"; break; default: text = "No value found"; } document.getElementById("demo").innerHTML = text; </script> </body> </html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now