Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
Closed
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
No difference.
Ninguna diferencia.
View file
Open in desktop
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`.

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?
View file
Open in desktop
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?');
}
```

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

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

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.
View file
Open in desktop
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 deletions1-js/02-first-steps/14-function-basics/3-min/solution.md
View file
Open in desktop
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 deletions1-js/02-first-steps/14-function-basics/3-min/task.md
View file
Open in desktop
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 deletions1-js/02-first-steps/14-function-basics/4-pow/solution.md
View file
Open in desktop
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,
usean integer greater than 0`);
alert(`Potencia ${n}no soportada,
useun entero mayor a 0`);
} else {
alert( pow(x, n) );
}
Expand Down
6 changes: 3 additions & 3 deletions1-js/02-first-steps/14-function-basics/4-pow/task.md
View file
Open in desktop
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 aweb-page that prompts for`x`and `n`,and then shows the result of `pow(x,n)`.
Crea una páginaweb 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

[8]ページ先頭

©2009-2025 Movatter.jp