Switch Statements are better to use if you know that there are going to be a limited number of answers
<script>
var command = "Open Sesame";
switch(command) {
case "Open Sesame":
document.write("You may enter");
break;//kicks you out of this case
case "Abracadabra":
document.write("I'm gonna reach out and grab yah");
break;
default://If none of these come back as true
document.write("That is not the magic word");
}
</script>
No comments:
Post a Comment