--- id: 587d7b7e367417b2b2512b21 title: Use Multiple Conditional (Ternary) Operators challengeType: 1 videoUrl: '' localeTitle: Usar múltiples operadores condicionales (ternarios) --- ## Description
En el desafío anterior, usaste un solo conditional operator . También puede encadenarlos para verificar múltiples condiciones. La siguiente función usa las declaraciones if, else if, y else para verificar múltiples condiciones:
función findGreaterOrEqual (a, b) {
si (a === b) {
devuelve "a y b son iguales";
}
si no (a> b) {
devuelve "a es mayor";
}
else {
el retorno "b es mayor";
}
}
La función anterior se puede reescribir utilizando múltiples conditional operators :
función findGreaterOrEqual (a, b) {
retorno (a === b)? "a y b son iguales": (a> b)? "a es mayor": "b es mayor";
}
## Instructions
Use múltiples conditional operators en la función checkSign para verificar si un número es positivo, negativo o cero.
## Tests
```yml tests: - text: checkSign debe usar múltiples conditional operators testString: 'assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?\s*?\?\s*?.+?\s*?:\s*?.+?/gi.test(code), "checkSign should use multiple conditional operators");' - text: checkSign(10) debe devolver "positivo". Tenga en cuenta que la capitalización importa testString: 'assert(checkSign(10) === "positive", "checkSign(10) should return "positive". Note that capitalization matters");' - text: checkSign(-12) debe devolver "negativo". Tenga en cuenta que la capitalización importa testString: 'assert(checkSign(-12) === "negative", "checkSign(-12) should return "negative". Note that capitalization matters");' - text: checkSign(0) debe devolver "cero". Tenga en cuenta que la capitalización importa testString: 'assert(checkSign(0) === "zero", "checkSign(0) should return "zero". Note that capitalization matters");' ```
## Challenge Seed
```js function checkSign(num) { } checkSign(10); ```
## Solution
```js // solution required ```