-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from otmon76/1.2.14
The "switch" statement
- Loading branch information
Showing
5 changed files
with
79 additions
and
79 deletions.
There are no files selected for viewing
24 changes: 12 additions & 12 deletions
24
1-js/02-first-steps/14-switch/1-rewrite-switch-if-else/solution.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
To precisely match the functionality of `switch`, the `if` must use a strict comparison `'==='`. | ||
Abychom dosáhli přesné funkcionality příkazu `switch`, musí `if` používat striktní rovnost `'==='`. | ||
|
||
For given strings though, a simple `'=='` works too. | ||
V tomto případě však pro zadané řetězce funguje i obyčejné `'=='`. | ||
|
||
```js no-beautify | ||
if(browser == 'Edge') { | ||
alert("You've got the Edge!"); | ||
} else if (browser == 'Chrome' | ||
|| browser == 'Firefox' | ||
|| browser == 'Safari' | ||
|| browser == 'Opera') { | ||
alert( 'Okay we support these browsers too' ); | ||
if(prohlížeč == 'Edge') { | ||
alert("Vy máte Edge!"); | ||
} else if (prohlížeč == 'Chrome' | ||
|| prohlížeč == 'Firefox' | ||
|| prohlížeč == 'Safari' | ||
|| prohlížeč == 'Opera') { | ||
alert( 'V pořádku, tyto prohlížeče také podporujeme' ); | ||
} else { | ||
alert( 'We hope that this page looks ok!' ); | ||
alert( 'Doufáme, že tato stránka vypadá dobře!' ); | ||
} | ||
``` | ||
|
||
Please note: the construct `browser == 'Chrome' || browser == 'Firefox' …` is split into multiple lines for better readability. | ||
Všimněte si, že konstrukce `prohlížeč == 'Chrome' || prohlížeč == 'Firefox' …` je pro lepší čitelnost rozdělena do několika řádků. | ||
|
||
But the `switch` construct is still cleaner and more descriptive. | ||
Ale i přesto je `switch` jasnější a přehlednější. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters