Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Ninguna diferencia.
No difference.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ importance: 4

---

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

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

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

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

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

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

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

```js
function checkAge(age) {
return (age > 18) ? true : confirm('¿Tús padres te lo permitieron?');
return (age > 18) ? true : confirm('Did parents allow you?');
}
```

Usando Ó `||` (la variante más corta):
Using OR `||` (the shortest variant):

```js
function checkAge(age) {
return (age > 18) || confirm('¿Tús padres te lo permitieron?');
return (age > 18) || confirm('Did parents allow you?');
}
```

Tenga en cuenta que los paréntesis alrededor de `age > 18` no son requeridos aca. Existen para una mejor legibilidad.
Note that the parentheses around `age > 18` are not required here. They exist for better readabilty.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ importance: 4

---

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

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

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

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

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

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

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

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

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

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

---

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

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

Por ejemplo:
For instance:

```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 number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ let x = prompt("x?", '');
let n = prompt("n?", '');

if (n < 1) {
alert(`Potencia ${n} no soportada,
use un entero mayor a 0`);
alert(`Power ${n} is not supported,
use an integer greater than 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 number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ importance: 4

# Function pow(x,n)

Escriba 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.
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.

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

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

[demo]

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