Switch case in javaScript

switch case in javaScript

Switch case like if else statement

Example

let option = 'c';

switch (option) {
    case "a": {
        console.log("Option matched with a");
        break;
    }
    case "b": {
        console.log("Option matched with b");
        break;
    }
    case "c": {
        console.log("Option matched with c");
        break;
    }
    default: {
        console.log("Default option");
        }
}

 

About Author

Photo

Hi, I am Mahbub Hasan
Software Engineer

I am very much interested to share my programming
and development knowledge with the people.I will try
to update my blog everyday with new technology inshallah.

Thank You

For Visiting My Blog.

Contact Me