26 lines
427 B
Markdown
26 lines
427 B
Markdown
importance: 5
|
|
|
|
---
|
|
|
|
# Rewrite the "switch" into an "if"
|
|
|
|
Write the code using `if..else` which would correspond to the following `switch`:
|
|
|
|
```js
|
|
switch (browser) {
|
|
case 'Edge':
|
|
alert( "You've got the Edge!" );
|
|
break;
|
|
|
|
case 'Chrome':
|
|
case 'Firefox':
|
|
case 'Safari':
|
|
case 'Opera':
|
|
alert( 'Okay we support these browsers too' );
|
|
break;
|
|
|
|
default:
|
|
alert( 'We hope that this page looks ok!' );
|
|
}
|
|
```
|
|
|