Switch statement example updated (#37757)
* Switch statement example updated * Update switch-statements.english.md example Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * Update switch-statements.english.md example Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
committed by
Randell Dawson
parent
2d647b1638
commit
c4dc0b297f
@ -8,20 +8,16 @@ forumTopicId: 18277
|
|||||||
|
|
||||||
## Description
|
## Description
|
||||||
<section id='description'>
|
<section id='description'>
|
||||||
If you have many options to choose from, use a <code>switch</code> statement. A <code>switch</code> statement tests a value and can have many <code>case</code> statements which define various possible values. Statements are executed from the first matched <code>case</code> value until a <code>break</code> is encountered.
|
If you have many options to choose from, use a <dfn>switch</dfn> statement. A <code>switch</code> statement tests a value and can have many <dfn>case</dfn> statements which define various possible values. Statements are executed from the first matched <code>case</code> value until a <code>break</code> is encountered.
|
||||||
Here is a <dfn>pseudocode</dfn> example:
|
Here is an example of a <code>switch</code> statement:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
switch(num) {
|
switch(lowercaseLetter) {
|
||||||
case value1:
|
case "a":
|
||||||
statement1;
|
console.log("A");
|
||||||
break;
|
break;
|
||||||
case value2:
|
case "b":
|
||||||
statement2;
|
console.log("B");
|
||||||
break;
|
|
||||||
...
|
|
||||||
case valueN:
|
|
||||||
statementN;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user