Update JavaScript switch statement (#2161)

add syntax highlighting in code snippet.
pull/2154/head^2
puru-khedre 2 years ago committed by GitHub
parent b6818a42ea
commit 7af71de4f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      content/roadmaps/106-javascript/content/107-javascript-control-flow/101-conditional-statements/101-switch.md

@ -1,8 +1,9 @@
# Switch # Switch Case
The `switch` statement evaluates an expression, matching the expression's value against a series of `case` clauses, and executes statements after the first `case` clause with a matching value, until a `break` statement is encountered. The `default` clause of a `switch` statement will be jumped to if no `case` matches the expression's value. The `switch` statement evaluates an expression, matching the expression's value against a series of `case` clauses, and executes statements after the first `case` clause with a matching value, until a `break` statement is encountered. The `default` clause of a `switch` statement will be jumped to if no `case` matches the expression's value.
``` ## Example
```js
switch (expression) { switch (expression) {
case value1: case value1:
//Statements executed when the result of expression matches value1 //Statements executed when the result of expression matches value1
@ -22,4 +23,4 @@ switch (expression) {
<ResourceGroupTitle>Free Content</ResourceGroupTitle> <ResourceGroupTitle>Free Content</ResourceGroupTitle>
<BadgeLink colorScheme='blue' badgeText='Read' href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch'>switch - MDN</BadgeLink> <BadgeLink colorScheme='blue' badgeText='Read' href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch'>switch - MDN</BadgeLink>
<BadgeLink colorScheme='blue' badgeText='Read' href='https://javascript.info/switch'>The switch statement</BadgeLink> <BadgeLink colorScheme='blue' badgeText='Read' href='https://javascript.info/switch'>The switch statement - javascript.info</BadgeLink>

Loading…
Cancel
Save