mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-29 06:26:22 +00:00
51 lines
942 B
Markdown
51 lines
942 B
Markdown
|
---
|
||
|
id: 7af3c0d0-b8aa-4619-81eb-cad43b3698bb
|
||
|
title: JavaScript Switch Statement
|
||
|
---
|
||
|
|
||
|
# Syntax
|
||
|
|
||
|
``` javascript
|
||
|
switch ("rainy") {
|
||
|
case "rainy":
|
||
|
console.log("Remember to bring an umbrella.");
|
||
|
break;
|
||
|
case "sunny":
|
||
|
console.log("Dress lightly.");
|
||
|
case "cloudy":
|
||
|
console.log("Go outside.");
|
||
|
break;
|
||
|
default:
|
||
|
console.log("Unknown weather type!");
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
switch ("sunny") {
|
||
|
case "rainy":
|
||
|
console.log("Remember to bring an umbrella.");
|
||
|
break;
|
||
|
case "sunny":
|
||
|
console.log("Dress lightly.");
|
||
|
case "cloudy":
|
||
|
console.log("Go outside.");
|
||
|
break;
|
||
|
default:
|
||
|
console.log("Unknown weather type!");
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
switch ("wild card") {
|
||
|
case "rainy":
|
||
|
console.log("Remember to bring an umbrella.");
|
||
|
break;
|
||
|
case "sunny":
|
||
|
console.log("Dress lightly.");
|
||
|
case "cloudy":
|
||
|
console.log("Go outside.");
|
||
|
break;
|
||
|
default:
|
||
|
console.log("Unknown weather type!");
|
||
|
break;
|
||
|
}
|
||
|
```
|