Jump to content

switch statement


frozentree

Recommended Posts

i have notice this.......switch statement Only works with document.bgcolor and .write.....is this true??

You can use the switch statement for anything.for example you are passing a variable to a function and want ot return a value based on the variable you passed in.
function doSwitch(myVar){    switch(myVar)    {        case "yes":            return "it said yes";            break;        case "no" :            return "it said no";            break;        case "maybe":            return "it's not sure";            break;        default:            return "something went wrong";            break;     }}

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...