Skip to content
Closed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
No difference.
Ninguna diferencia.
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,11 @@ importance: 4

---

# Is "else" required?
# ¿Es "else" requerido?

The following function returns `true` if the parameter `age` is greater than `18`.
La siguiente función devuelve `true` si el parámetro `age` es mayour a `18`.
Comment thread
Giorgiosaud marked this conversation as resolved.

Otherwise it asks for a confirmation and returns its result:
De lo contrario, solicita una confirmación y devuelve su resultado:

```js
function checkAge(age) {
Expand All@@ -15,13 +15,13 @@ function checkAge(age) {
*!*
} else {
// ...
return confirm('Did parents allow you?');
return confirm('¿Tus padres te dieron permiso?');
}
*/!*
}
```

Will the function work differently if `else` is removed?
¿Funcionará la función de manera diferente si se borra `else`?

```js
function checkAge(age) {
Expand All@@ -30,9 +30,9 @@ function checkAge(age) {
}
*!*
// ...
return confirm('Did parents allow you?');
return confirm('¿Tus padres te permitieron?');
*/!*
}
```

Is there any difference in the behavior of these two variants?
¿Hay alguna diferencia en el comportamiento de estas dos variantes?
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,16 +2,16 @@ Using a question mark operator `'?'`:

```js
function checkAge(age) {
return (age > 18) ? true : confirm('Did parents allow you?');
return (age > 18) ? true : confirm('¿Tús padres te lo permitieron?');
Comment thread
Giorgiosaud marked this conversation as resolved.
}
```

Using OR `||` (the shortest variant):
Usando Ó `||` (la variante más corta):
Comment thread
Giorgiosaud marked this conversation as resolved.

```js
function checkAge(age) {
return (age > 18) || confirm('Did parents allow you?');
return (age > 18) || confirm('¿Tús padres te lo permitieron?');
Comment thread
Giorgiosaud marked this conversation as resolved.
}
```

Note that the parentheses around `age > 18` are not required here. They exist for better readabilty.
Ten en cuenta que los paréntesis alrededor de `age > 18` no son requeridos aqui. Existen para una mejor legibilidad.
Comment thread
Giorgiosaud marked this conversation as resolved.
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,25 +2,25 @@ importance: 4

---

# Rewrite the function using '?' or '||'
# Reescribe la función utilizando '?' o '||'

The following function returns `true` if the parameter `age` is greater than `18`.
La siguiente función devuelve `true` si el parámetro `age` es mayor que `18`.

Otherwise it asks for a confirmation and returns its result.
De lo contrario, solicita una confirmación y devuelve su resultado.

```js
function checkAge(age) {
if (age > 18) {
return true;
} else {
return confirm('Do you have your parents permission to access this page?');
return confirm('¿Tienes permiso de tus padres para acceder a esta página?');
}
}
```

Rewrite it, to perform the same, but without `if`, in a single line.
Reescríbelo, para realizar lo mismo, pero sin `if`, en una sola linea.

Make two variants of `checkAge`:
Haz dos variantes de `checkAge`:

1. Using a question mark operator `?`
2. Using OR `||`
1. Usando un operador de signo de interrogación `?`
2. Usando OR `||`
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/14-function-basics/3-min/solution.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,12 +10,12 @@ function min(a, b) {
}
```

A solution with a question mark operator `'?'`:
Una solución con un operador de signo de interrogación `'?'`:

```js
function min(a, b) {
return a < b ? a : b;
}
```

P.S. In the case of an equality `a == b` it does not matter what to return.
P.D: En el caso de una igualdad `a == b` no importa qué devuelva.
6 changes: 3 additions & 3 deletions 1-js/02-first-steps/14-function-basics/3-min/task.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,11 @@ importance: 1

---

# Function min(a, b)
# Función min(a, b)

Write a function `min(a,b)` which returns the least of two numbers `a` and `b`.
Escribe una función `min(a,b)` la cual devuelva el menor de dos números `a` y `b`.

For instance:
Por ejemplo:

```js
min(2, 5) == 2
Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/14-function-basics/4-pow/solution.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,8 +14,8 @@ let x = prompt("x?", '');
let n = prompt("n?", '');

if (n < 1) {
alert(`Power ${n} is not supported,
use an integer greater than 0`);
alert(`Potencia ${n} no soportada,
use un entero mayor a 0`);
} else {
alert( pow(x, n) );
}
Expand Down
6 changes: 3 additions & 3 deletions 1-js/02-first-steps/14-function-basics/4-pow/task.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,16 +4,16 @@ importance: 4

# Function pow(x,n)

Write a function `pow(x,n)` that returns `x` in power `n`. Or, in other words, multiplies `x` by itself `n` times and returns the result.
Escribe la función `pow(x,n)` que devuelva `x` como potencia de `n`. O, en otras palabras, multiplique `x` por si mismo `n` veces y devuelva el resultado.

```js
pow(3, 2) = 3 * 3 = 9
pow(3, 3) = 3 * 3 * 3 = 27
pow(1, 100) = 1 * 1 * ...* 1 = 1
```

Create a web-page that prompts for `x` and `n`, and then shows the result of `pow(x,n)`.
Crea una página web que solicite `x` y `n`, y luego muestra el resultado de `pow(x,n)`.

[demo]

P.S. In this task the function should support only natural values of `n`: integers up from `1`.
PD: En esta tarea, la función solo debe admitir valores naturales de `n`: enteros hacia por encima de `1`.
Loading