Javascript switch statement switch on String

Description

Javascript switch statement switch on String


let weatherType = "cold";

switch (weatherType) {
    case "sunny":
        console.log("It's sunny outside! Go out and play!");
        break;/*  w w  w  . ja  va  2 s.  c  o m*/
    case "rainy":
        console.log("It's rainy outside! Stay inside!");
        break;
    case "cloudy":
        console.log("It's cloudy outside. Stay in or go out.");
        break;
    case "windy":
        console.log("It's windy outside! Carry a jacket!");
        break;
    case "cold":
        console.log("It's cold outside! Don't forget your coat!");
        break;
    default:
        console.log("I don't know that type of weather");
        break;
}



PreviousNext

Related