Se si dispone di molte opzioni tra cui scegliere, un'istruzione `switch` può essere più facile da scrivere rispetto a molte istruzioni `if`/`else if` concatenate. Il seguente:
```js
if (val === 1) {
answer = "a";
} else if (val === 2) {
answer = "b";
} else {
answer = "c";
}
```
può essere sostituito con:
```js
switch(val) {
case 1:
answer = "a";
break;
case 2:
answer = "b";
break;
default:
answer = "c";
}
```
# --instructions--
Cambiare le istruzioni `if`/`else if` concatenate con un'istruzione `switch`.
# --hints--
Non dovresti usare nessuna istruzione `else` nell'editor
```js
assert(!/else/g.test(code));
```
Non dovresti usare nessuna istruzione `if` nell'editor
```js
assert(!/if/g.test(code));
```
Dovresti avere almeno quattro istruzioni `break`
```js
assert(code.match(/break/g).length >= 4);
```
`chainToSwitch("bob")` dovrebbe essere la stringa `Marley`
```js
assert(chainToSwitch('bob') === 'Marley');
```
`chainToSwitch(42)` dovrebbe essere la stringa `The Answer`
```js
assert(chainToSwitch(42) === 'The Answer');
```
`chainToSwitch(1)` dovrebbe essere la stringa `There is no #1`
```js
assert(chainToSwitch(1) === 'There is no #1');
```
`chainToSwitch(99)` dovrebbe essere la stringa `Missed me by this much!`
```js
assert(chainToSwitch(99) === 'Missed me by this much!');
```
`chainToSwitch(7)` dovrebbe essere la stringa `Ate Nine`
```js
assert(chainToSwitch(7) === 'Ate Nine');
```
`chainToSwitch("John")` dovrebbe essere `""` (stringa vuota)
```js
assert(chainToSwitch('John') === '');
```
`chainToSwitch(156)` dovrebbe essere `""` (stringa vuota)