Mega Code Archive

 
Categories / JavaScript DHTML / Language Basics
 

Switch with string value

<html> <head> <title></title> </head> <body> <script type="text/javascript"> var inputName = prompt("Please enter your name:"); switch(inputName) {     case "Tom":         document.write("Welcome " + inputName);         break;     case "Name":         document.write("Name");         break;     default:         document.write("default:" + inputName); } </script> </body> </html>