From 76be9f668884f747aff04247aa1d093ed0e996b9 Mon Sep 17 00:00:00 2001 From: vplentinax Date: Fri, 5 Jun 2020 13:26:33 -0400 Subject: [PATCH 01/31] Giorgiosaud-PR95-correccion --- .../1-if-else-required/solution.md | 2 +- .../1-if-else-required/task.md | 14 +- .../solution.md | 8 +- .../2-rewrite-function-question-or/task.md | 16 +- .../15-function-basics/3-min/solution.md | 4 +- .../15-function-basics/3-min/task.md | 6 +- .../15-function-basics/4-pow/solution.md | 4 +- .../15-function-basics/4-pow/task.md | 6 +- .../15-function-basics/article.md | 295 +++++++++--------- 9 files changed, 178 insertions(+), 177 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md b/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md index e41c80418..1fef812fb 100644 --- a/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md +++ b/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md @@ -1 +1 @@ -No difference. \ No newline at end of file +Ninguna diferencia. diff --git a/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md b/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md index 4f69a5c8c..e3e721c39 100644 --- a/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md +++ b/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md @@ -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) { @@ -15,13 +15,13 @@ function checkAge(age) { *!* } else { // ... - return confirm('Did parents allow you?'); + return confirm('¿Tus padres te permitieron?'); } */!* } ``` -Will the function work differently if `else` is removed? +¿Funcionará la función de manera diferente si se borra `else`? ```js function checkAge(age) { @@ -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? diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md index c8ee9618f..1b2d819f8 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md @@ -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. +Tenga en cuenta que los paréntesis alrededor de `age > 18` no son requeridos aca. Existen para una mejor legibilidad. diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md index 523bb127a..f62c638cb 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md @@ -2,25 +2,25 @@ importance: 4 --- -# Rewrite the function using '?' or '||' +# Reescriba 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 parametro `age` es mayour 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íbalo, 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 Ó `||` diff --git a/1-js/02-first-steps/15-function-basics/3-min/solution.md b/1-js/02-first-steps/15-function-basics/3-min/solution.md index 2236d9203..b8964c874 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/solution.md +++ b/1-js/02-first-steps/15-function-basics/3-min/solution.md @@ -10,7 +10,7 @@ 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) { @@ -18,4 +18,4 @@ function min(a, b) { } ``` -P.S. In the case of an equality `a == b` it does not matter what to return. \ No newline at end of file +P.D: En el caso de una igualdad `a == b` No importa qué devuelva. diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index 50edd0d36..d784a3b5f 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -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`. +Escriba 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 diff --git a/1-js/02-first-steps/15-function-basics/4-pow/solution.md b/1-js/02-first-steps/15-function-basics/4-pow/solution.md index 5ef20c386..772ec5fa7 100644 --- a/1-js/02-first-steps/15-function-basics/4-pow/solution.md +++ b/1-js/02-first-steps/15-function-basics/4-pow/solution.md @@ -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) ); } diff --git a/1-js/02-first-steps/15-function-basics/4-pow/task.md b/1-js/02-first-steps/15-function-basics/4-pow/task.md index f569320c7..fda0a956e 100644 --- a/1-js/02-first-steps/15-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/15-function-basics/4-pow/task.md @@ -4,7 +4,7 @@ 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. +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. ```js pow(3, 2) = 3 * 3 = 9 @@ -12,8 +12,8 @@ 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)`. +Cree 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`. diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 874890ab5..37ae8566a 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -1,36 +1,36 @@ -# Functions +# Funciones -Quite often we need to perform a similar action in many places of the script. +Muy a menudo necesitamos realizar una acción similar en muchos lugares del script. -For example, we need to show a nice-looking message when a visitor logs in, logs out and maybe somewhere else. +Por ejemplo, debemos mostrar un mensaje atractivo cuando un visitante inicia sesión, cierra sesión y tal vez en otros momentos. -Functions are the main "building blocks" of the program. They allow the code to be called many times without repetition. +Las funciones son los principales "bloques de construcción" del programa. Permiten que el código se llame muchas veces sin repetición. -We've already seen examples of built-in functions, like `alert(message)`, `prompt(message, default)` and `confirm(question)`. But we can create functions of our own as well. +Ya hemos visto ejemplos de funciones integradas, como `alert(message)`, `prompt(message, default)` y `confirm(question)`. Pero también podemos crear funciones propias. -## Function Declaration +## Declaración de funcicones -To create a function we can use a *function declaration*. +Para crear una función podemos usar una *declaración de function*. -It looks like this: +Se Parece a esto: ```js function showMessage() { - alert( 'Hello everyone!' ); + alert( '¡Hola a todos!' ); } ``` -The `function` keyword goes first, then goes the *name of the function*, then a list of *parameters* between the parentheses (empty in the example above) and finally the code of the function, also named "the function body", between curly braces. +La palabra clave `function` va primero, luego una lista de *parámetros* entre paréntesis (vacía en el ejemplo anterior) y finalmente el código de la función, también llamado "el cuerpo de la función" , entre llaves. ![](function_basics.png) -Our new function can be called by its name: `showMessage()`. +Nuestra nueva función puede ser llamada por su nombre: `showMessage()`. -For instance: +Por ejemplo: ```js run function showMessage() { - alert( 'Hello everyone!' ); + alert( '¡Hola a todos!' ); } *!* @@ -39,125 +39,125 @@ showMessage(); */!* ``` -The call `showMessage()` executes the code of the function. Here we will see the message two times. +La llamada `showMessage()` ejecuta el código de la función. Aquí veremos el mensaje dos veces. -This example clearly demonstrates one of the main purposes of functions: to avoid code duplication. +Este ejemplo demuestra claramente uno de los propósitos principales de las funciones: evitar la duplicación de código.. -If we ever need to change the message or the way it is shown, it's enough to modify the code in one place: the function which outputs it. +Si alguna vez necesitamos cambiar el mensaje o la forma en que se muestra, es suficiente modificar el código en un lugar: la función que lo genera. -## Local variables +## Variables Locales -A variable declared inside a function is only visible inside that function. +Una variable declarada dentro de una función solo es visible dentro de esa función. -For example: +Por ejemplo: ```js run function showMessage() { *!* - let message = "Hello, I'm JavaScript!"; // local variable + let message = "Hola, ¡Soy JavaScript!"; // local variable */!* alert( message ); } -showMessage(); // Hello, I'm JavaScript! +showMessage(); // Hola, ¡Soy JavaScript!! -alert( message ); // <-- Error! The variable is local to the function +alert( message ); // <-- Error! La variable es local para esta función ``` -## Outer variables +## Variables Externas -A function can access an outer variable as well, for example: +Una función también puede acceder a una variable externa, por ejemplo: ```js run no-beautify -let *!*userName*/!* = 'John'; +let *!*userName*/!* = 'Juan'; function showMessage() { - let message = 'Hello, ' + *!*userName*/!*; + let message = 'Hola, ' + *!*userName*/!*; alert(message); } -showMessage(); // Hello, John +showMessage(); // Hola, Juan ``` -The function has full access to the outer variable. It can modify it as well. +La función tiene acceso completo a la variable externa. Puede modificarlo también. -For instance: +Por ejemplo: ```js run -let *!*userName*/!* = 'John'; +let *!*userName*/!* = 'Juan'; function showMessage() { - *!*userName*/!* = "Bob"; // (1) changed the outer variable + *!*userName*/!* = "Bob"; // (1) Cambió la variable externa - let message = 'Hello, ' + *!*userName*/!*; + let message = 'Hola, ' + *!*userName*/!*; alert(message); } -alert( userName ); // *!*John*/!* before the function call +alert( userName ); // *!*Juan*/!* antes de llamar la función showMessage(); -alert( userName ); // *!*Bob*/!*, the value was modified by the function +alert( userName ); // *!*Bob*/!*, el valor fué modificado por la función ``` -The outer variable is only used if there's no local one. So an occasional modification may happen if we forget `let`. +La variable externa solo se usa si no hay una local. Por lo tanto, puede ocurrir una modificación ocasional si olvidamos colocar el `let`. -If a same-named variable is declared inside the function then it *shadows* the outer one. For instance, in the code below the function uses the local `userName`. The outer one is ignored: +Si una variable con el mismo nombre se declara dentro de la función, entonces *hace shadowing a* la externa. Por ejemplo, en el siguiente código, la función usa el `userName` local. El exterior se ignora: ```js run -let userName = 'John'; +let userName = 'Juan'; function showMessage() { *!* - let userName = "Bob"; // declare a local variable + let userName = "Bob"; // declara variable local */!* let message = 'Hello, ' + userName; // *!*Bob*/!* alert(message); } -// the function will create and use its own userName +// la función crea y utiliza su propia variable local userName showMessage(); -alert( userName ); // *!*John*/!*, unchanged, the function did not access the outer variable +alert( userName ); // *!*John*/!*, se mantiene, la función no accedió a la variable externa ``` -```smart header="Global variables" -Variables declared outside of any function, such as the outer `userName` in the code above, are called *global*. +```smart header="Variables globales" +Variables declaradas fuera de cualquier función, como el la variable externa `userName` en el código anterior, se llaman *global*. -Global variables are visible from any function (unless shadowed by locals). +Las variables globales son visibles desde cualquier función (a menos que estén se haga shadowing en el contexto local). -Usually, a function declares all variables specific to its task. Global variables only store project-level data, and it's important that these variables are accessible from anywhere. Modern code has few or no globals. Most variables reside in their functions. +Por lo general, una función declara todas las variables específicas de su tarea. Las variables globales solo almacenan datos a nivel de proyecto, y es importante que estas variables sean accesibles desde cualquier lugar. El código moderno tiene pocos o ninguna variable global. La mayoría de las variables residen en sus funciones. ``` -## Parameters +## Parámetros -We can pass arbitrary data to functions using parameters (also called *function arguments*) . +Podemos pasar datos arbitrarios a funciones usando parámetros (también llamados *argumentos de función*). -In the example below, the function has two parameters: `from` and `text`. +En el siguiente ejemplo, la función tiene dos parámetros: `from` y `text`. ```js run -function showMessage(*!*from, text*/!*) { // arguments: from, text +function showMessage(*!*from, text*/!*) { // argumentos: from, text alert(from + ': ' + text); } *!* -showMessage('Ann', 'Hello!'); // Ann: Hello! (*) -showMessage('Ann', "What's up?"); // Ann: What's up? (**) +showMessage('Ann', 'Hola!'); // Ann: Hola! (*) +showMessage('Ann', "¿Como estás?"); // Ann: ¿Como estás? (**) */!* ``` -When the function is called in lines `(*)` and `(**)`, the given values are copied to local variables `from` and `text`. Then the function uses them. +Cuando la función se llama `(*)` y `(**)`, los valores dados se copian en variables locales `from` y `text`. Y la función las utiliza. -Here's one more example: we have a variable `from` and pass it to the function. Please note: the function changes `from`, but the change is not seen outside, because a function always gets a copy of the value: +Aquí hay un ejemplo más: tenemos una variable `from` y la pasamos a la función. Tenga en cuenta: la función cambia `from`, pero el cambio no se ve afuera, porque una función siempre obtiene una copia del valor: ```js run function showMessage(from, text) { *!* - from = '*' + from + '*'; // make "from" look nicer + from = '*' + from + '*'; // hace que "from" se vea mejor */!* alert( from + ': ' + text ); @@ -165,62 +165,62 @@ function showMessage(from, text) { let from = "Ann"; -showMessage(from, "Hello"); // *Ann*: Hello +showMessage(from, "Hola"); // *Ann*: Hola -// the value of "from" is the same, the function modified a local copy +// el valor de "from" es el mismo, la función modificó una copia local alert( from ); // Ann ``` -## Default values +## Valores predeterminado -If a parameter is not provided, then its value becomes `undefined`. +Si no se proporciona un parámetro, su valor se convierte en `undefined`. -For instance, the aforementioned function `showMessage(from, text)` can be called with a single argument: +Por ejemplo, la función mencionada anteriormente `showMessage(from, text)` se puede llamar con un solo argumento: ```js showMessage("Ann"); ``` -That's not an error. Such a call would output `"Ann: undefined"`. There's no `text`, so it's assumed that `text === undefined`. +Eso no es un error. la llamada saldría `"Ann: undefined"`. No existe el parámetro `text`, entonces asumimos que `text === undefined`. -If we want to use a "default" `text` in this case, then we can specify it after `=`: +Si quisieramos usar un `text` "predeterminado" en este caso, lo podemos identificar despues del `=`: ```js run -function showMessage(from, *!*text = "no text given"*/!*) { +function showMessage(from, *!*text = "sin texto"*/!*) { alert( from + ": " + text ); } -showMessage("Ann"); // Ann: no text given +showMessage("Ann"); // Ann: sin texto ``` -Now if the `text` parameter is not passed, it will get the value `"no text given"` +Ahora si no existe el parámetro `text`, obtendrá el valor `"sin texto"` -Here `"no text given"` is a string, but it can be a more complex expression, which is only evaluated and assigned if the parameter is missing. So, this is also possible: +Aquí `"sin texto"` es un string, pero puede ser una expresión mas compleja, la cual solo es evaluada y asignada si el parámetro falta. Entonces, esto es posible: ```js run function showMessage(from, text = anotherFunction()) { - // anotherFunction() only executed if no text given - // its result becomes the value of text + // anotherFunction() solo se ejecuta si el parámetro texto no fué asignado + // y su resultado se convierte en el valor de texto } ``` -```smart header="Evaluation of default parameters" +```smart header="Evaluación de parámetros predeterminado" -In JavaScript, a default parameter is evaluated every time the function is called without the respective parameter. In the example above, `anotherFunction()` is called every time `showMessage()` is called without the `text` parameter. This is in contrast to some other languages like Python, where any default parameters are evaluated only once during the initial interpretation. +En JavaScript, se evalúa un parámetro predeterminado cada vez que se llama a la función sin el parámetro respectivo. En el ejemplo anterior, se llama a `anotherFunction ()` cada vez que se llama a `showMessage ()` sin el parámetro `text`. Esto contrasta con otros lenguajes como Python, donde los parámetros predeterminados se evalúan solo una vez durante la interpretación inicial. ``` -````smart header="Default parameters old-style" -Old editions of JavaScript did not support default parameters. So there are alternative ways to support them, that you can find mostly in the old scripts. +````smart header="Parámetros predeterminados de estilo antiguo" +Las ediciones anteriores de JavaScript no admitían parámetros predeterminados. Por lo tanto, hay formas alternativas de apoyarlos, que se pueden encontrar principalmente en los scripts antiguos. -For instance, an explicit check for being `undefined`: +Por ejemplo, una comprobación explícita de ser `undefined`: ```js function showMessage(from, text) { *!* if (text === undefined) { - text = 'no text given'; + text = 'sin texto'; } */!* @@ -228,12 +228,12 @@ function showMessage(from, text) { } ``` -...Or the `||` operator: +...O el operador `||` ```js function showMessage(from, text) { - // if text is falsy then text gets the "default" value - text = text || 'no text given'; + // si text es falso entonces text se convierte en el valor "predeterminado" + text = text || 'sin texto'; ... } ``` @@ -242,11 +242,11 @@ function showMessage(from, text) { ```` -## Returning a value +## Devolviendo un valor -A function can return a value back into the calling code as the result. +Una función puede devolver un valor al código de llamada como resultado. -The simplest example would be a function that sums two values: +El ejemplo más simple sería una función que suma dos valores: ```js run no-beautify function sum(a, b) { @@ -257,9 +257,9 @@ let result = sum(1, 2); alert( result ); // 3 ``` -The directive `return` can be in any place of the function. When the execution reaches it, the function stops, and the value is returned to the calling code (assigned to `result` above). +La directiva `return` puede estar en cualquier lugar de la función. Cuando la ejecución lo alcanza, la función se detiene y el valor se devuelve al código de llamada (asignado al `result` anterior). -There may be many occurrences of `return` in a single function. For instance: +Puede haber muchos casos de `return ` en una sola función. Por ejemplo: ```js run function checkAge(age) { @@ -269,23 +269,24 @@ function checkAge(age) { */!* } else { *!* - return confirm('Do you have permission from your parents?'); + return confirm('¿Tienes permiso de tus padres?'); */!* } } -let age = prompt('How old are you?', 18); +let age = prompt('¿Que edad tienes?', 18); if ( checkAge(age) ) { - alert( 'Access granted' ); + alert( 'Acceso otorgado' ); } else { - alert( 'Access denied' ); + alert( 'Acceso denegado' ); } ``` -It is possible to use `return` without a value. That causes the function to exit immediately. +Es posible utilizar `return` sin ningun valor. Eso hace que la función salga o termine inmediatamente. -For example: + +Por ejemplo: ```js function showMovie(age) { @@ -295,15 +296,15 @@ function showMovie(age) { */!* } - alert( "Showing you the movie" ); // (*) + alert( "Mostrandote la película" ); // (*) // ... } ``` -In the code above, if `checkAge(age)` returns `false`, then `showMovie` won't proceed to the `alert`. +Enel codigo de arriba, si `checkAge(age)` devuelve `false`, entonces `showMovie` no mostrará la `alert`. -````smart header="A function with an empty `return` or without it returns `undefined`" -If a function does not return a value, it is the same as if it returns `undefined`: +````smart header="Una función con un `return` vacio o sin el devuelve `undefined`" +Si una función no devuelve un valor, es lo mismo que si devuelve `undefined`: ```js run function doNothing() { /* empty */ } @@ -311,7 +312,7 @@ function doNothing() { /* empty */ } alert( doNothing() === undefined ); // true ``` -An empty `return` is also the same as `return undefined`: +Un `return` vacío también es lo mismo que `return undefined`: ```js run function doNothing() { @@ -322,80 +323,80 @@ alert( doNothing() === undefined ); // true ``` ```` -````warn header="Never add a newline between `return` and the value" -For a long expression in `return`, it might be tempting to put it on a separate line, like this: +````warn header="Nunca agregue una nueva línea entre `return` y el valor" +Para una expresion larga de `return`, puede ser tentador ponerlo en una línea separada, como esta: ```js return - (some + long + expression + or + whatever * f(a) + f(b)) + (una + expresion + o + cualquier + cosa * f(a) + f(b)) ``` -That doesn't work, because JavaScript assumes a semicolon after `return`. That'll work the same as: +Eso no funciona, porque JavaScript asume un punto y coma después del `return`. Eso funcionará igual que: ```js return*!*;*/!* - (some + long + expression + or + whatever * f(a) + f(b)) + (una + expresion + o + cualquier + cosa * f(a) + f(b)) ``` -So, it effectively becomes an empty return. We should put the value on the same line instead. +Entonces, efectivamente se convierte en un return vacío. Deberíamos poner el valor en la misma línea. ```` -## Naming a function [#function-naming] +## Nomenclatura de funciones [#function-naming] -Functions are actions. So their name is usually a verb. It should be brief, as accurate as possible and describe what the function does, so that someone reading the code gets an indication of what the function does. +Las funciones son acciones. Entonces su nombre suele ser un verbo. Debe ser breve, lo más preciso posible y describir lo que hace la función, para que alguien que lea el código obtenga una indicación de lo que hace la función. -It is a widespread practice to start a function with a verbal prefix which vaguely describes the action. There must be an agreement within the team on the meaning of the prefixes. +Es una práctica generalizada comenzar una función con un prefijo verbal que describe vagamente la acción. Debe haber un acuerdo dentro del equipo sobre el significado de los prefijos. -For instance, functions that start with `"show"` usually show something. +Por ejemplo, funciones que comienzan con `"show"` usualmente muestran algo. -Function starting with... +Funciónes que comienza con... -- `"get…"` -- return a value, -- `"calc…"` -- calculate something, -- `"create…"` -- create something, -- `"check…"` -- check something and return a boolean, etc. +- `"get…"` -- devuelven un valor, +- `"calc…"` -- calcúlan algo, +- `"create…"` -- crean algo, +- `"check…"` -- revisan algo y devuelven un boolean, etc. -Examples of such names: +Ejemplos de este tipo de nombres: ```js no-beautify -showMessage(..) // shows a message -getAge(..) // returns the age (gets it somehow) -calcSum(..) // calculates a sum and returns the result -createForm(..) // creates a form (and usually returns it) -checkPermission(..) // checks a permission, returns true/false +showMessage(..) // muestra un mensaje +getAge(..) // devuelve la edad (la obtiene de alguna manera) +calcSum(..) // calcula una suma y devuelve el resultado +createForm(..) // crea un formulario (y usualmente lo devuelve) +checkPermission(..) // revisa permisos, y devuelve true/false ``` -With prefixes in place, a glance at a function name gives an understanding what kind of work it does and what kind of value it returns. +Con los prefijos en su lugar, un vistazo al nombre de una función permite comprender qué tipo de trabajo realiza y qué tipo de valor devuelve. -```smart header="One function -- one action" -A function should do exactly what is suggested by its name, no more. +```smart header="Una función -- una acción" +Una función debe hacer exactamente lo que sugiere su nombre, no más. -Two independent actions usually deserve two functions, even if they are usually called together (in that case we can make a 3rd function that calls those two). +Dos acciones independientes por lo general merecen dos funciones, incluso si generalmente se convocan juntas (en ese caso, podemos hacer una tercera función que llame a esas dos). -A few examples of breaking this rule: +Algunos ejemplos de como se rompen estas reglas: -- `getAge` -- would be bad if it shows an `alert` with the age (should only get). -- `createForm` -- would be bad if it modifies the document, adding a form to it (should only create it and return). -- `checkPermission` -- would be bad if it displays the `access granted/denied` message (should only perform the check and return the result). +- `getAge` -- sería malo si muestra una `alert` con la edad (solo debería obtener). +- `createForm` -- sería malo si modifica el documento y lo agrega (solo debe crearlo y devolverlo). +- `checkPermission` -- sería malo si muestra el mensaje `acceso otorgsado/denegado`(solo debe realizar la verificación y devolver el resultado). -These examples assume common meanings of prefixes. What they mean for you is determined by you and your team. Maybe it's pretty normal for your code to behave differently. But you should have a firm understanding of what a prefix means, what a prefixed function can and cannot do. All same-prefixed functions should obey the rules. And the team should share the knowledge. +Estos ejemplos asumen significados comunes de prefijos. Lo que significan para ti está determinado por ti y tu equipo. Tal vez es bastante normal que su código se comporte de manera diferente. Pero debe tener una comprensión firme de lo que significa un prefijo, lo que una función con prefijo puede y no puede hacer. Todas las funciones con el mismo prefijo deben obedecer las reglas. Y el equipo debe compartir el conocimiento. ``` -```smart header="Ultrashort function names" -Functions that are used *very often* sometimes have ultrashort names. +```smart header="Nombres de funciones ultracortos" +Las funciones que se utilizan *muy a menudo* algunas veces tienen nombres ultracortos. -For example, the [jQuery](http://jquery.com) framework defines a function with `$`. The [LoDash](http://lodash.com/) library has its core function named `_`. +Por ejemplo, el framework [jQuery](http://jquery.com) define una función con `$`. La librería [LoDash](http://lodash.com/) tiene como nombre de funccion principal `_`. -These are exceptions. Generally functions names should be concise and descriptive. +Estas son excepciones. En general, los nombres de las funciones deben ser concisos y descriptivos. ``` -## Functions == Comments +## Funciones == Comentarios -Functions should be short and do exactly one thing. If that thing is big, maybe it's worth it to split the function into a few smaller functions. Sometimes following this rule may not be that easy, but it's definitely a good thing. +Las funciones deben ser cortas y hacer exactamente una cosa. Si esa cosa es grande, tal vez valga la pena dividir la función en algunas funciones más pequeñas. A veces, seguir esta regla puede no ser tan fácil, pero definitivamente es algo bueno. -A separate function is not only easier to test and debug -- its very existence is a great comment! +Una función separada no solo es más fácil de probar y depurar, -- ¡su existencia es un gran comentario! -For instance, compare the two functions `showPrimes(n)` below. Each one outputs [prime numbers](https://en.wikipedia.org/wiki/Prime_number) up to `n`. +Por ejemplo, comparemos las dos funciones `showPrimes(n)` siguientes. Cada una devuelve [números primos](https://en.wikipedia.org/wiki/Prime_number) hasta `n`. -The first variant uses a label: +La primera variante usa una etiqueta: ```js function showPrimes(n) { @@ -405,12 +406,12 @@ function showPrimes(n) { if (i % j == 0) continue nextPrime; } - alert( i ); // a prime + alert( i ); // un número primo } } ``` -The second variant uses an additional function `isPrime(n)` to test for primality: +La segunda variante usa una función adicional `isPrime(n)` para probar la primalidad: ```js function showPrimes(n) { @@ -430,32 +431,32 @@ function isPrime(n) { } ``` -The second variant is easier to understand, isn't it? Instead of the code piece we see a name of the action (`isPrime`). Sometimes people refer to such code as *self-describing*. +La segunda variante es más fácil de entender, ¿no? En lugar del código, vemos un nombre de la acción. (`isPrime`). A veces las personas se refieren a dicho código como *autodescriptivo*. -So, functions can be created even if we don't intend to reuse them. They structure the code and make it readable. +Por lo tanto, las funciones se pueden crear incluso si no tenemos la intención de reutilizarlas. Estructuran el código y lo hacen legible. -## Summary +## Resumen -A function declaration looks like this: +Una declaración de función se ve así: ```js -function name(parameters, delimited, by, comma) { +function name(parámetros, delimitados, por, coma) { /* code */ } ``` -- Values passed to a function as parameters are copied to its local variables. -- A function may access outer variables. But it works only from inside out. The code outside of the function doesn't see its local variables. -- A function can return a value. If it doesn't, then its result is `undefined`. +- Los valores pasados a una función como parámetros se copian a sus variables locales. +- Una función puede acceder a variables externas. Pero funciona solo de adentro hacia afuera. El código fuera de la función no ve sus variables locales. +- Una función puede devolver un valor. Si no lo hace, entonces su resultado es `undefined`. -To make the code clean and easy to understand, it's recommended to use mainly local variables and parameters in the function, not outer variables. +Para que el código sea limpio y fácil de entender, se recomienda utilizar principalmente variables y parámetros locales en la función, no variables externas. -It is always easier to understand a function which gets parameters, works with them and returns a result than a function which gets no parameters, but modifies outer variables as a side-effect. +Siempre es más fácil entender una función que obtiene parámetros, trabaja con ellos y devuelve un resultado que una función que no obtiene parámetros, pero modifica las variables externas como un efecto secundario. -Function naming: +Nomenclatura de funciones: -- A name should clearly describe what the function does. When we see a function call in the code, a good name instantly gives us an understanding what it does and returns. -- A function is an action, so function names are usually verbal. -- There exist many well-known function prefixes like `create…`, `show…`, `get…`, `check…` and so on. Use them to hint what a function does. +- Un nombre debe describir claramente lo que hace la función. Cuando vemos una llamada a la función en el código, un buen nombre nos da al instante una comprensión de lo que hace y devuelve. +- Una función es una acción, por lo que los nombres de las funciones suelen ser verbales. +- Existen muchos prefijos de funciones bien conocidos como `create…`, `show…`, `get…`, `check…` y así. Úsalos para insinuar lo que hace una función. -Functions are the main building blocks of scripts. Now we've covered the basics, so we actually can start creating and using them. But that's only the beginning of the path. We are going to return to them many times, going more deeply into their advanced features. +Las funciones son los principales bloques de construcción de los guiones. Ahora hemos cubierto los conceptos básicos, por lo que en realidad podemos comenzar a crearlos y usarlos. Pero ese es solo el comienzo del camino. Volveremos a ellos muchas veces, profundizando en sus funciones avanzadas. From f95071e10245ac2bd3e4b738b7bc0b4ffab7394e Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:05:59 -0300 Subject: [PATCH 02/31] Update 1-js/02-first-steps/15-function-basics/1-if-else-required/task.md --- .../15-function-basics/1-if-else-required/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md b/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md index e3e721c39..328118e9f 100644 --- a/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md +++ b/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md @@ -4,7 +4,7 @@ importance: 4 # ¿Es "else" requerido? -La siguiente función devuelve `true` si el parámetro `age` es mayour a `18`. +La siguiente función devuelve `true` si el parámetro `age` es mayor a `18`. De lo contrario, solicita una confirmación y devuelve su resultado: From 09ffe2a70dd12a320805fe82b9faa0f4e90180ca Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:06:17 -0300 Subject: [PATCH 03/31] Update 1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md --- .../15-function-basics/2-rewrite-function-question-or/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md index f62c638cb..af137f24e 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md @@ -4,7 +4,7 @@ importance: 4 # Reescriba la función utilizando '?' o '||' -La siguiente función devuelve `true` si el parametro `age` es mayour que `18`. +La siguiente función devuelve `true` si el parametro `age` es mayor que `18`. De lo contrario, solicita una confirmación y devuelve su resultado. From 70b78b873288337a2b244f7020b1bb271e891b2a Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:06:28 -0300 Subject: [PATCH 04/31] Update 1-js/02-first-steps/15-function-basics/article.md --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 37ae8566a..d2c712177 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -10,7 +10,7 @@ Ya hemos visto ejemplos de funciones integradas, como `alert(message)`, `prompt( ## Declaración de funcicones -Para crear una función podemos usar una *declaración de function*. +Para crear una función podemos usar una *declaración de función*. Se Parece a esto: From bdfa86a61bdb35fbec7362111df371a9871563b0 Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:06:40 -0300 Subject: [PATCH 05/31] Update 1-js/02-first-steps/15-function-basics/article.md --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index d2c712177..cbe0aeac0 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -54,7 +54,7 @@ Por ejemplo: ```js run function showMessage() { *!* - let message = "Hola, ¡Soy JavaScript!"; // local variable + let message = "Hola, ¡Soy JavaScript!"; // variable local */!* alert( message ); From f92cde2800e4504f5779a5224a9eff7e09d65006 Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:06:49 -0300 Subject: [PATCH 06/31] Update 1-js/02-first-steps/15-function-basics/article.md --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index cbe0aeac0..6dfe82487 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -60,7 +60,7 @@ function showMessage() { alert( message ); } -showMessage(); // Hola, ¡Soy JavaScript!! +showMessage(); // Hola, ¡Soy JavaScript! alert( message ); // <-- Error! La variable es local para esta función ``` From 71c8b5fcef796ae989348a3368c32608bd9d5a0d Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:07:01 -0300 Subject: [PATCH 07/31] Update 1-js/02-first-steps/15-function-basics/article.md --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 6dfe82487..8492cd2df 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -301,7 +301,7 @@ function showMovie(age) { } ``` -Enel codigo de arriba, si `checkAge(age)` devuelve `false`, entonces `showMovie` no mostrará la `alert`. +En el código de arriba, si `checkAge(age)` devuelve `false`, entonces `showMovie` no mostrará la `alert`. ````smart header="Una función con un `return` vacio o sin el devuelve `undefined`" Si una función no devuelve un valor, es lo mismo que si devuelve `undefined`: From 37463e9c54ad7a55a8d718dd28ac4cf1579f22f9 Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:07:10 -0300 Subject: [PATCH 08/31] Update 1-js/02-first-steps/15-function-basics/article.md --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 8492cd2df..93e96745e 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -328,7 +328,7 @@ Para una expresion larga de `return`, puede ser tentador ponerlo en una línea s ```js return - (una + expresion + o + cualquier + cosa * f(a) + f(b)) + (una + expresion + o + cualquier + cosa * f(a) + f(b)) ``` Eso no funciona, porque JavaScript asume un punto y coma después del `return`. Eso funcionará igual que: From 70e926b4e59b6a9700a21c1ef87fa682f2b282c5 Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:07:33 -0300 Subject: [PATCH 09/31] Update 1-js/02-first-steps/15-function-basics/article.md --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 93e96745e..166feafec 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -334,7 +334,7 @@ Eso no funciona, porque JavaScript asume un punto y coma después del `return`. ```js return*!*;*/!* - (una + expresion + o + cualquier + cosa * f(a) + f(b)) + (una + expresion + o + cualquier + cosa * f(a) + f(b)) ``` Entonces, efectivamente se convierte en un return vacío. Deberíamos poner el valor en la misma línea. ```` From 03bc402382c741f5fb41ed18a981768490b1f098 Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:07:45 -0300 Subject: [PATCH 10/31] Update 1-js/02-first-steps/15-function-basics/article.md --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 166feafec..325a356a0 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -394,7 +394,7 @@ Las funciones deben ser cortas y hacer exactamente una cosa. Si esa cosa es gran Una función separada no solo es más fácil de probar y depurar, -- ¡su existencia es un gran comentario! -Por ejemplo, comparemos las dos funciones `showPrimes(n)` siguientes. Cada una devuelve [números primos](https://en.wikipedia.org/wiki/Prime_number) hasta `n`. +Por ejemplo, comparemos las dos funciones `showPrimes(n)` siguientes. Cada una devuelve [números primos](https://es.wikipedia.org/wiki/N%C3%BAmero_primo) hasta `n`. La primera variante usa una etiqueta: From d5c47ee726323fc2ef5137a1ba1e443b6527c3fc Mon Sep 17 00:00:00 2001 From: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> Date: Mon, 15 Jun 2020 11:07:54 -0300 Subject: [PATCH 11/31] Update 1-js/02-first-steps/15-function-basics/article.md --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 325a356a0..10c5f1212 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -459,4 +459,4 @@ Nomenclatura de funciones: - Una función es una acción, por lo que los nombres de las funciones suelen ser verbales. - Existen muchos prefijos de funciones bien conocidos como `create…`, `show…`, `get…`, `check…` y así. Úsalos para insinuar lo que hace una función. -Las funciones son los principales bloques de construcción de los guiones. Ahora hemos cubierto los conceptos básicos, por lo que en realidad podemos comenzar a crearlos y usarlos. Pero ese es solo el comienzo del camino. Volveremos a ellos muchas veces, profundizando en sus funciones avanzadas. +Las funciones son los principales bloques de construcción de los scripts. Ahora hemos cubierto los conceptos básicos, por lo que en realidad podemos comenzar a crearlos y usarlos. Pero ese es solo el comienzo del camino. Volveremos a ellos muchas veces, profundizando en sus funciones avanzadas. From f6655c0fb1c533d8d3a7faa162ef3eaa185c443c Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Tue, 16 Jun 2020 12:35:17 -0400 Subject: [PATCH 12/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 10c5f1212..a3a14dddb 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -103,7 +103,7 @@ alert( userName ); // *!*Bob*/!*, el valor fué modificado por la función La variable externa solo se usa si no hay una local. Por lo tanto, puede ocurrir una modificación ocasional si olvidamos colocar el `let`. -Si una variable con el mismo nombre se declara dentro de la función, entonces *hace shadowing a* la externa. Por ejemplo, en el siguiente código, la función usa el `userName` local. El exterior se ignora: +Si una variable con el mismo nombre se declara dentro de la función, entonces *hace shadowing* a la externa. Por ejemplo, en el siguiente código, la función usa el `userName` local. El exterior se ignora: ```js run let userName = 'Juan'; From 023b516d89cf0babf6149cbb31a4d1b9de4c6f8d Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Tue, 16 Jun 2020 12:35:30 -0400 Subject: [PATCH 13/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index a3a14dddb..52baf7c59 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -124,7 +124,7 @@ alert( userName ); // *!*John*/!*, se mantiene, la función no accedió a la var ``` ```smart header="Variables globales" -Variables declaradas fuera de cualquier función, como el la variable externa `userName` en el código anterior, se llaman *global*. +Variables declaradas fuera de cualquier función, como la variable externa `userName` en el código anterior, se llaman *global*. Las variables globales son visibles desde cualquier función (a menos que estén se haga shadowing en el contexto local). From 25dfc7fd5177a8792c7f3055c6e6385151c93404 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Tue, 16 Jun 2020 12:35:42 -0400 Subject: [PATCH 14/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 52baf7c59..ff25ea541 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -126,7 +126,7 @@ alert( userName ); // *!*John*/!*, se mantiene, la función no accedió a la var ```smart header="Variables globales" Variables declaradas fuera de cualquier función, como la variable externa `userName` en el código anterior, se llaman *global*. -Las variables globales son visibles desde cualquier función (a menos que estén se haga shadowing en el contexto local). +Las variables globales son visibles desde cualquier función (a menos que se haga shadowing en el contexto local). Por lo general, una función declara todas las variables específicas de su tarea. Las variables globales solo almacenan datos a nivel de proyecto, y es importante que estas variables sean accesibles desde cualquier lugar. El código moderno tiene pocos o ninguna variable global. La mayoría de las variables residen en sus funciones. ``` From f4e78a7427a23bb8db0502d7ff30f27ca4c8f26d Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Tue, 16 Jun 2020 12:35:58 -0400 Subject: [PATCH 15/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index ff25ea541..e8eeab32c 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -171,7 +171,7 @@ showMessage(from, "Hola"); // *Ann*: Hola alert( from ); // Ann ``` -## Valores predeterminado +## Valores predeterminados Si no se proporciona un parámetro, su valor se convierte en `undefined`. From d944b06115255629aec901b438d181a2e5093189 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Tue, 16 Jun 2020 12:36:09 -0400 Subject: [PATCH 16/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index e8eeab32c..705d025a7 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -206,7 +206,7 @@ function showMessage(from, text = anotherFunction()) { ```smart header="Evaluación de parámetros predeterminado" -En JavaScript, se evalúa un parámetro predeterminado cada vez que se llama a la función sin el parámetro respectivo. En el ejemplo anterior, se llama a `anotherFunction ()` cada vez que se llama a `showMessage ()` sin el parámetro `text`. Esto contrasta con otros lenguajes como Python, donde los parámetros predeterminados se evalúan solo una vez durante la interpretación inicial. +En JavaScript, se evalúa un parámetro predeterminado cada vez que se llama a la función sin el parámetro respectivo. En el ejemplo anterior, se llama a `anotherFunction()` cada vez que se llama a `showMessage()` sin el parámetro `text`. Esto contrasta con otros lenguajes como Python, donde los parámetros predeterminados se evalúan solo una vez durante la interpretación inicial. ``` From 6e083122027d611a8b3bfdc4b4e50de4f60fbf3f Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Tue, 16 Jun 2020 12:36:35 -0400 Subject: [PATCH 17/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: Ezequiel Castellanos <51804994+ezzep66@users.noreply.github.com> --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 705d025a7..3d39df3b2 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -212,7 +212,7 @@ En JavaScript, se evalúa un parámetro predeterminado cada vez que se llama a l ````smart header="Parámetros predeterminados de estilo antiguo" -Las ediciones anteriores de JavaScript no admitían parámetros predeterminados. Por lo tanto, hay formas alternativas de apoyarlos, que se pueden encontrar principalmente en los scripts antiguos. +Las ediciones anteriores de JavaScript no admitían parámetros predeterminados. Por lo tanto, hay formas alternativas de admitirlos, que se pueden encontrar principalmente en los scripts antiguos. Por ejemplo, una comprobación explícita de ser `undefined`: From 05538ed14b57760c8f529f1bdbae09521de22408 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:51:47 -0400 Subject: [PATCH 18/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 3d39df3b2..53d3f4a47 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -8,7 +8,7 @@ Las funciones son los principales "bloques de construcción" del programa. Permi Ya hemos visto ejemplos de funciones integradas, como `alert(message)`, `prompt(message, default)` y `confirm(question)`. Pero también podemos crear funciones propias. -## Declaración de funcicones +## Declaración de funciones Para crear una función podemos usar una *declaración de función*. From bd731dc1482b6eb1125e7ec9aa444a271efaf242 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:52:02 -0400 Subject: [PATCH 19/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 53d3f4a47..a219f0d83 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -143,7 +143,7 @@ function showMessage(*!*from, text*/!*) { // argumentos: from, text } *!* -showMessage('Ann', 'Hola!'); // Ann: Hola! (*) +showMessage('Ann', '¡Hola!'); // Ann: ¡Hola! (*) showMessage('Ann', "¿Como estás?"); // Ann: ¿Como estás? (**) */!* ``` From 7312c8ffefd6dc287bafd7d36fc80b77ab9f3f57 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:52:16 -0400 Subject: [PATCH 20/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index a219f0d83..57eaca67a 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -144,7 +144,7 @@ function showMessage(*!*from, text*/!*) { // argumentos: from, text *!* showMessage('Ann', '¡Hola!'); // Ann: ¡Hola! (*) -showMessage('Ann', "¿Como estás?"); // Ann: ¿Como estás? (**) +showMessage('Ann', "¿Cómo estás?"); // Ann: ¿Cómo estás? (**) */!* ``` From 06a0d8f1ecd5a8e876bf98908c7595da515de5af Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:52:28 -0400 Subject: [PATCH 21/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 57eaca67a..268f12a5e 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -183,7 +183,7 @@ showMessage("Ann"); Eso no es un error. la llamada saldría `"Ann: undefined"`. No existe el parámetro `text`, entonces asumimos que `text === undefined`. -Si quisieramos usar un `text` "predeterminado" en este caso, lo podemos identificar despues del `=`: +Si quisiéramos usar un `text` "predeterminado" en este caso, lo podemos identificar después del `=`: ```js run function showMessage(from, *!*text = "sin texto"*/!*) { From 3dde6f32098474932c33d4c483a119ea6d7baa6f Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:52:40 -0400 Subject: [PATCH 22/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 268f12a5e..ca942b978 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -193,7 +193,7 @@ function showMessage(from, *!*text = "sin texto"*/!*) { showMessage("Ann"); // Ann: sin texto ``` -Ahora si no existe el parámetro `text`, obtendrá el valor `"sin texto"` +Ahora, si no existe el parámetro `text`, obtendrá el valor `"sin texto"` Aquí `"sin texto"` es un string, pero puede ser una expresión mas compleja, la cual solo es evaluada y asignada si el parámetro falta. Entonces, esto es posible: From 22dec625cede06b3ebfd2fa8d5b906618a0e6efb Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:52:53 -0400 Subject: [PATCH 23/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index ca942b978..e79dcc253 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -195,7 +195,7 @@ showMessage("Ann"); // Ann: sin texto Ahora, si no existe el parámetro `text`, obtendrá el valor `"sin texto"` -Aquí `"sin texto"` es un string, pero puede ser una expresión mas compleja, la cual solo es evaluada y asignada si el parámetro falta. Entonces, esto es posible: +Aquí `"sin texto"` es un string, pero puede ser una expresión más compleja, la cual solo es evaluada y asignada si el parámetro falta. Entonces, esto es posible: ```js run function showMessage(from, text = anotherFunction()) { From 7776d6e91d80782be5979bbeb8b86e0104d5bfa9 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:53:07 -0400 Subject: [PATCH 24/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index e79dcc253..fbc3a165c 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -274,7 +274,7 @@ function checkAge(age) { } } -let age = prompt('¿Que edad tienes?', 18); +let age = prompt('¿Qué edad tienes?', 18); if ( checkAge(age) ) { alert( 'Acceso otorgado' ); From fb1b96f68d24bd101d9e501a829bcf8ec65a4dd7 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:53:18 -0400 Subject: [PATCH 25/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index fbc3a165c..bb084da5f 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -283,7 +283,7 @@ if ( checkAge(age) ) { } ``` -Es posible utilizar `return` sin ningun valor. Eso hace que la función salga o termine inmediatamente. +Es posible utilizar `return` sin ningún valor. Eso hace que la función salga o termine inmediatamente. Por ejemplo: From 86af996ee65d38a83e02d1fd414712b82bf07489 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:53:32 -0400 Subject: [PATCH 26/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index bb084da5f..150a3ca2c 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -296,7 +296,7 @@ function showMovie(age) { */!* } - alert( "Mostrandote la película" ); // (*) + alert( "Mostrándote la película" ); // (*) // ... } ``` From 5b73d94eca53128946af167e6a6271f0935ba125 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:53:53 -0400 Subject: [PATCH 27/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 150a3ca2c..7a8b454b6 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -324,7 +324,7 @@ alert( doNothing() === undefined ); // true ```` ````warn header="Nunca agregue una nueva línea entre `return` y el valor" -Para una expresion larga de `return`, puede ser tentador ponerlo en una línea separada, como esta: +Para una expresión larga de `return`, puede ser tentador ponerlo en una línea separada, como esta: ```js return From b889666a7218d8fb2104f7bd426faf8a7c2ceb5e Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:54:21 -0400 Subject: [PATCH 28/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 7a8b454b6..f663ce719 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -347,7 +347,7 @@ Es una práctica generalizada comenzar una función con un prefijo verbal que de Por ejemplo, funciones que comienzan con `"show"` usualmente muestran algo. -Funciónes que comienza con... +Funciones que comienza con... - `"get…"` -- devuelven un valor, - `"calc…"` -- calcúlan algo, From ca8c18d6356e51b7acdaabf8f6c67ce5e2a23882 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:54:39 -0400 Subject: [PATCH 29/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index f663ce719..799617260 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -350,7 +350,7 @@ Por ejemplo, funciones que comienzan con `"show"` usualmente muestran algo. Funciones que comienza con... - `"get…"` -- devuelven un valor, -- `"calc…"` -- calcúlan algo, +- `"calc…"` -- calculan algo, - `"create…"` -- crean algo, - `"check…"` -- revisan algo y devuelven un boolean, etc. From 9f1b86db48c23f42c0f5a3baa7497286bed6ad16 Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:54:50 -0400 Subject: [PATCH 30/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 799617260..17993f551 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -371,7 +371,7 @@ Una función debe hacer exactamente lo que sugiere su nombre, no más. Dos acciones independientes por lo general merecen dos funciones, incluso si generalmente se convocan juntas (en ese caso, podemos hacer una tercera función que llame a esas dos). -Algunos ejemplos de como se rompen estas reglas: +Algunos ejemplos de cómo se rompen estas reglas: - `getAge` -- sería malo si muestra una `alert` con la edad (solo debería obtener). - `createForm` -- sería malo si modifica el documento y lo agrega (solo debe crearlo y devolverlo). From bd45ddd50763420ac24e94035eb82e128527114f Mon Sep 17 00:00:00 2001 From: Valentina VP <34555644+vplentinax@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:54:59 -0400 Subject: [PATCH 31/31] Update 1-js/02-first-steps/15-function-basics/article.md Co-authored-by: joaquinelio --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 17993f551..735045702 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -373,7 +373,7 @@ Dos acciones independientes por lo general merecen dos funciones, incluso si gen Algunos ejemplos de cómo se rompen estas reglas: -- `getAge` -- sería malo si muestra una `alert` con la edad (solo debería obtener). +- `getAge` -- sería malo si mostrara una `alert` con la edad (solo debería obtener). - `createForm` -- sería malo si modifica el documento y lo agrega (solo debe crearlo y devolverlo). - `checkPermission` -- sería malo si muestra el mensaje `acceso otorgsado/denegado`(solo debe realizar la verificación y devolver el resultado).