--- id: 56533eb9ac21ba0edf2244de title: Adding a Default Option in Switch Statements challengeType: 1 guideUrl: 'https://spanish.freecodecamp.org/guide/certificates/adding-a-default-option-in-switch-statements' videoUrl: '' localeTitle: Adición de una opción predeterminada en los estados de cambio --- ## Description
En una declaración de switch , es posible que no pueda especificar todos los valores posibles como declaraciones de case . En su lugar, puede agregar la declaración default que se ejecutará si no se encuentran declaraciones de case coincidentes. Piense en ello como la última instrucción else en una cadena if/else . Una declaración por default debe ser el último caso.
interruptor (núm) {
valor de caso1:
sentencia1;
descanso;
valor de caso2:
declaración2;
descanso;
...
defecto:
declaración por defecto;
descanso;
}
## Instructions
Escriba una instrucción de cambio para establecer la answer para las siguientes condiciones:
"a" - "manzana"
"b" - "pájaro"
"c" - "gato"
default - "cosas"
## Tests
```yml tests: - text: switchOfStuff("a") debe tener un valor de "apple" testString: 'assert(switchOfStuff("a") === "apple", "switchOfStuff("a") should have a value of "apple"");' - text: switchOfStuff("b") debe tener un valor de "bird" testString: 'assert(switchOfStuff("b") === "bird", "switchOfStuff("b") should have a value of "bird"");' - text: switchOfStuff("c") debe tener un valor de "cat" testString: 'assert(switchOfStuff("c") === "cat", "switchOfStuff("c") should have a value of "cat"");' - text: switchOfStuff("d") debe tener un valor de "cosas" testString: 'assert(switchOfStuff("d") === "stuff", "switchOfStuff("d") should have a value of "stuff"");' - text: switchOfStuff(4) debe tener un valor de "cosas" testString: 'assert(switchOfStuff(4) === "stuff", "switchOfStuff(4) should have a value of "stuff"");' - text: No debes usar ninguna declaración if o else testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any if or else statements");' - text: Debes usar una declaración por default testString: 'assert(switchOfStuff("string-to-trigger-default-case") === "stuff", "You should use a default statement");' - text: Debe tener al menos 3 declaraciones de break testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 break statements");' ```
## Challenge Seed
```js function switchOfStuff(val) { var answer = ""; // Only change code below this line // Only change code above this line return answer; } // Change this value to test switchOfStuff(1); ```
## Solution
```js // solution required ```