- Notifications
You must be signed in to change notification settings - Fork230
Functions#96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Functions#96
Changes fromall commits
486eeaa5f8016717663f48caa7d772b1d6b5609c64899980f5f51d7d68ce777e064e9ce1dfe5fbaacc42f6f6bb7634171eFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| Ninguna diferencia. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,11 +2,11 @@ importance: 4 | ||
| --- | ||
| #¿Es "else"requerido? | ||
| La siguiente función devuelve `true`si el parámetro `age`es mayour a `18`. | ||
Giorgiosaud marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| De lo contrario, solicita una confirmación y devuelve su resultado: | ||
| ```js | ||
| function checkAge(age) { | ||
| @@ -15,13 +15,13 @@ function checkAge(age) { | ||
| *!* | ||
| } else { | ||
| // ... | ||
| return confirm('¿Tus padres te dieron permiso?'); | ||
| } | ||
| */!* | ||
| } | ||
| ``` | ||
| ¿Funcionará la función de manera diferente si se borra`else`? | ||
| ```js | ||
| function checkAge(age) { | ||
| @@ -30,9 +30,9 @@ function checkAge(age) { | ||
| } | ||
| *!* | ||
| // ... | ||
| return confirm('¿Tus padres te permitieron?'); | ||
| */!* | ||
| } | ||
| ``` | ||
| ¿Hay alguna diferencia en el comportamiento de estas dos variantes? | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,16 +2,16 @@ Using a question mark operator `'?'`: | ||
| ```js | ||
| function checkAge(age) { | ||
| return (age > 18) ? true : confirm('¿Tús padres te lo permitieron?'); | ||
Giorgiosaud marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
| ``` | ||
| Usando Ó `||` (la variante más corta): | ||
Giorgiosaud marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| ```js | ||
| function checkAge(age) { | ||
| return (age > 18) || confirm('¿Tús padres te lo permitieron?'); | ||
Giorgiosaud marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
| ``` | ||
| Ten en cuenta que los paréntesis alrededor de`age > 18`no son requeridos aqui. Existen para una mejor legibilidad. | ||
Giorgiosaud marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
Uh oh!
There was an error while loading.Please reload this page.