From 9d205697c12efd916dfbe1f840c8873cd604122a Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Thu, 15 Aug 2019 22:51:24 -0300 Subject: [PATCH 01/14] Update solution.md --- .../14-function-basics/1-if-else-required/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/14-function-basics/1-if-else-required/solution.md b/1-js/02-first-steps/14-function-basics/1-if-else-required/solution.md index e41c80418..023257922 100644 --- a/1-js/02-first-steps/14-function-basics/1-if-else-required/solution.md +++ b/1-js/02-first-steps/14-function-basics/1-if-else-required/solution.md @@ -1 +1 @@ -No difference. \ No newline at end of file +Sem diferença. From 97fa55369e7dd242b2783c9004ebbb9f943faca5 Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Thu, 15 Aug 2019 22:52:02 -0300 Subject: [PATCH 02/14] Update task.md --- .../14-function-basics/1-if-else-required/task.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/1-js/02-first-steps/14-function-basics/1-if-else-required/task.md b/1-js/02-first-steps/14-function-basics/1-if-else-required/task.md index 4f69a5c8c..8557afa9c 100644 --- a/1-js/02-first-steps/14-function-basics/1-if-else-required/task.md +++ b/1-js/02-first-steps/14-function-basics/1-if-else-required/task.md @@ -2,11 +2,11 @@ importance: 4 --- -# Is "else" required? +# "else" é obrigatório? -The following function returns `true` if the parameter `age` is greater than `18`. +A função a seguir retorna `true` se o parâmetro `age` é maior que `18`. -Otherwise it asks for a confirmation and returns its result: +Caso contrário, pede uma confirmação e retorna seu resultado: ```js function checkAge(age) { @@ -15,13 +15,13 @@ function checkAge(age) { *!* } else { // ... - return confirm('Did parents allow you?'); + return confirm('Seus pais permitiram?'); } */!* } ``` -Will the function work differently if `else` is removed? +A função funcionará diferentemente se `else` for removido? ```js function checkAge(age) { @@ -30,9 +30,9 @@ function checkAge(age) { } *!* // ... - return confirm('Did parents allow you?'); + return confirm('Seus pais permitiram?'); */!* } ``` -Is there any difference in the behavior of these two variants? +Existe alguma diferença no comportamento dessas duas variantes? From 6c72ebe7af653d6b031ab639ae68cff190fd3bfe Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Thu, 15 Aug 2019 22:52:46 -0300 Subject: [PATCH 03/14] Update solution.md --- .../2-rewrite-function-question-or/solution.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/solution.md b/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/solution.md index c8ee9618f..fb1cf01ae 100644 --- a/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/solution.md +++ b/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/solution.md @@ -1,17 +1,17 @@ -Using a question mark operator `'?'`: +Usando operador de interrogação `'?'`: ```js function checkAge(age) { - return (age > 18) ? true : confirm('Did parents allow you?'); + return (age > 18) ? true : confirm('Seus pais permitiram?'); } ``` -Using OR `||` (the shortest variant): +Usando OR `||` (A variante mais curta): ```js function checkAge(age) { - return (age > 18) || confirm('Did parents allow you?'); + return (age > 18) || confirm('Seus pais permitiram?'); } ``` -Note that the parentheses around `age > 18` are not required here. They exist for better readabilty. +Note que os parêntesis em volta de `age > 18` não são obrigatórios aqui. Eles existem para melhor legibilidade. From 315096d5f0a170cd50e25e5d08624e271c8f9ba7 Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Thu, 15 Aug 2019 22:53:20 -0300 Subject: [PATCH 04/14] Update task.md --- .../2-rewrite-function-question-or/task.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md index 523bb127a..384f818ea 100644 --- a/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md @@ -2,25 +2,25 @@ importance: 4 --- -# Rewrite the function using '?' or '||' +# Reescreva a função usando '?' ou '||' -The following function returns `true` if the parameter `age` is greater than `18`. +A função a seguir retorna `true` se o parâmetro `age` é maior que `18`. -Otherwise it asks for a confirmation and returns its result. +Caso contrário, pede por uma confirmação e retorna seu 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('Você tem permissão de seus pais para acessar esta página?'); } } ``` -Rewrite it, to perform the same, but without `if`, in a single line. +Reescreva, to perform the same, mas sem `if`, em uma única linha. -Make two variants of `checkAge`: +Faça duas variantes de `checkAge`: -1. Using a question mark operator `?` -2. Using OR `||` +1. Usando um operador de interrogação `?` +2. Usando OR `||` From b31095851d7d925777093a88dd278cacdb752a95 Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Thu, 15 Aug 2019 22:53:55 -0300 Subject: [PATCH 05/14] Update solution.md --- 1-js/02-first-steps/14-function-basics/3-min/solution.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/1-js/02-first-steps/14-function-basics/3-min/solution.md b/1-js/02-first-steps/14-function-basics/3-min/solution.md index 2236d9203..5ef8960b0 100644 --- a/1-js/02-first-steps/14-function-basics/3-min/solution.md +++ b/1-js/02-first-steps/14-function-basics/3-min/solution.md @@ -1,4 +1,4 @@ -A solution using `if`: +Uma solução usando `if`: ```js function min(a, b) { @@ -10,7 +10,7 @@ function min(a, b) { } ``` -A solution with a question mark operator `'?'`: +Uma solução com o operador de interrogação `'?'`: ```js function min(a, b) { @@ -18,4 +18,5 @@ 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.S. No caso de igualdade `a == b`, não importa o que retorna. + From c08f987778310434ebdec4cb1ffc2dc3fbaf2f38 Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Thu, 15 Aug 2019 22:54:14 -0300 Subject: [PATCH 06/14] Update task.md --- 1-js/02-first-steps/14-function-basics/3-min/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/14-function-basics/3-min/task.md b/1-js/02-first-steps/14-function-basics/3-min/task.md index 50edd0d36..3bdab4db4 100644 --- a/1-js/02-first-steps/14-function-basics/3-min/task.md +++ b/1-js/02-first-steps/14-function-basics/3-min/task.md @@ -4,9 +4,9 @@ importance: 1 # Function min(a, b) -Write a function `min(a,b)` which returns the least of two numbers `a` and `b`. +Escreva uma função `min(a,b)` no qual retorna o menor de dois números `a` e `b`. -For instance: +Por exemplo: ```js min(2, 5) == 2 From 2a20f1749fab767e47a0f3f90fc065f696637b95 Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Thu, 15 Aug 2019 22:54:38 -0300 Subject: [PATCH 07/14] Update solution.md --- 1-js/02-first-steps/14-function-basics/4-pow/solution.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/14-function-basics/4-pow/solution.md b/1-js/02-first-steps/14-function-basics/4-pow/solution.md index 5ef20c386..1db536294 100644 --- a/1-js/02-first-steps/14-function-basics/4-pow/solution.md +++ b/1-js/02-first-steps/14-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(`Expoente ${n} não é suportado, + use um inteiro maior que 0`); } else { alert( pow(x, n) ); } From 0a6e147084ea28e14b1494d2d616a5b04b0dde73 Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Thu, 15 Aug 2019 22:55:27 -0300 Subject: [PATCH 08/14] Update task.md --- 1-js/02-first-steps/14-function-basics/4-pow/task.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/1-js/02-first-steps/14-function-basics/4-pow/task.md b/1-js/02-first-steps/14-function-basics/4-pow/task.md index f569320c7..140677995 100644 --- a/1-js/02-first-steps/14-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/14-function-basics/4-pow/task.md @@ -1,10 +1,10 @@ -importance: 4 +importância: 4 --- -# Function pow(x,n) +# Função 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. +Escreva uma função `pow(x,n)` que retorna `x` no expoente `n`. Ou, em outras palavras, multiplica `x` por si mesmo `n` vezes e retorna um 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)`. +Crie uma página web that prompts para `x` e `n`, e depois mostre o resultado de `pow(x,n)`. [demo] -P.S. In this task the function should support only natural values of `n`: integers up from `1`. +P.S. Nesta tarefa, a função deve suportar apenas valores naturais de `n`: inteiros acima de` 1`. From fb2827ac9584116d7f9a4e87e5232f27b5745479 Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Sun, 18 Aug 2019 10:37:23 -0300 Subject: [PATCH 09/14] Update task.md --- 1-js/02-first-steps/14-function-basics/4-pow/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/14-function-basics/4-pow/task.md b/1-js/02-first-steps/14-function-basics/4-pow/task.md index 140677995..4a9969d1f 100644 --- a/1-js/02-first-steps/14-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/14-function-basics/4-pow/task.md @@ -1,4 +1,4 @@ -importância: 4 +importance: 4 --- From 98d821959fdddd4d809c74643d3470866cd84b6c Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Sun, 18 Aug 2019 10:39:26 -0300 Subject: [PATCH 10/14] Update solution.md --- 1-js/02-first-steps/14-function-basics/3-min/solution.md | 1 - 1 file changed, 1 deletion(-) diff --git a/1-js/02-first-steps/14-function-basics/3-min/solution.md b/1-js/02-first-steps/14-function-basics/3-min/solution.md index 5ef8960b0..093656ebd 100644 --- a/1-js/02-first-steps/14-function-basics/3-min/solution.md +++ b/1-js/02-first-steps/14-function-basics/3-min/solution.md @@ -19,4 +19,3 @@ function min(a, b) { ``` P.S. No caso de igualdade `a == b`, não importa o que retorna. - From b2c05c8eb2136d0a17c3ed44698a76c9c93f6763 Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Sun, 18 Aug 2019 10:48:22 -0300 Subject: [PATCH 11/14] Update task.md --- 1-js/02-first-steps/14-function-basics/4-pow/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/14-function-basics/4-pow/task.md b/1-js/02-first-steps/14-function-basics/4-pow/task.md index 4a9969d1f..f75772567 100644 --- a/1-js/02-first-steps/14-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/14-function-basics/4-pow/task.md @@ -12,7 +12,7 @@ pow(3, 3) = 3 * 3 * 3 = 27 pow(1, 100) = 1 * 1 * ...* 1 = 1 ``` -Crie uma página web that prompts para `x` e `n`, e depois mostre o resultado de `pow(x,n)`. +Crie uma página web que solicite `x` e `n`, em seguida, mostre o resultado de `pow(x,n)`. [demo] From 261b01f9199e4dad2b6a51d4ada48a6955219299 Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Sun, 18 Aug 2019 10:53:32 -0300 Subject: [PATCH 12/14] Update task.md --- .../14-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/14-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md index 384f818ea..f59647409 100644 --- a/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md @@ -18,7 +18,7 @@ function checkAge(age) { } ``` -Reescreva, to perform the same, mas sem `if`, em uma única linha. +Reescreva, para executar a mesma, mas sem `if`, em uma única linha. Faça duas variantes de `checkAge`: From 4496e706b6225d0362b0d93fa127eedc4c26aa3d Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Sun, 18 Aug 2019 11:47:17 -0300 Subject: [PATCH 13/14] Update article.md --- .../14-function-basics/article.md | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/1-js/02-first-steps/14-function-basics/article.md b/1-js/02-first-steps/14-function-basics/article.md index 18833cbf1..1a4b0c94a 100644 --- a/1-js/02-first-steps/14-function-basics/article.md +++ b/1-js/02-first-steps/14-function-basics/article.md @@ -1,36 +1,36 @@ -# Functions +# Funções -Quite often we need to perform a similar action in many places of the script. +Muitas vezes nós precisamos realizar uma ação semelhante em muitos lugares do script. -For example, we need to show a nice-looking message when a visitor logs in, logs out and maybe somewhere else. +Por exemplo, precisamos mostrar uma boa mensagem quando um usuário efetua login, efetua logout e talvez em outro lugar. -Functions are the main "building blocks" of the program. They allow the code to be called many times without repetition. +Funções são os principais "building blocks" do programa. Elas permitem que o código sejam chamados muitas vezes sem repetição. -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. +Nós já vimos exemplos de built-in functions, como `alert(message)`, `prompt(message, default)` e `confirm(question)`. Mas nós podemos criar funções próprias também. ## Function Declaration -To create a function we can use a *function declaration*. +Para criarmos uma função podemos usar uma *function declaration*. -It looks like this: +Se parece assim: ```js function showMessage() { - alert( 'Hello everyone!' ); + alert( 'Olá 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. +A palavra-chave `function` vem primeiro, depois vem o *nome da função*, e uma lista de *parâmetros* entre os parêntesis (vazio no exemplo acima) e finalmente o código da função, também chamado de "o corpo da função", entre chaves. ![](function_basics.png) -Our new function can be called by its name: `showMessage()`. +Nossa nova função pode ser chamada pelo seu nome: `showMessage()`. -For instance: +Por exemplo: ```js run function showMessage() { - alert( 'Hello everyone!' ); + alert( 'Olá a todos!' ); } *!* @@ -39,11 +39,11 @@ showMessage(); */!* ``` -The call `showMessage()` executes the code of the function. Here we will see the message two times. +A chamada `showMessage()` executa o código da função. Aqui vemos a mensagem duas vezes. -This example clearly demonstrates one of the main purposes of functions: to avoid code duplication. +Este exemplo demonstra claramente um dos principais objetivos das funções: evitar código duplicado. -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. +Se precisarmos mudar a mensagem ou a maneira que ela é mostrada, basta modificar o código em um só lugar: a função que gera isso. ## Local variables From 90a5d1baddef813b9b73f0f175b7e31c122ecafc Mon Sep 17 00:00:00 2001 From: Dheyson Alves Date: Wed, 21 Aug 2019 11:14:11 -0300 Subject: [PATCH 14/14] Update article.md --- 1-js/02-first-steps/14-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/14-function-basics/article.md b/1-js/02-first-steps/14-function-basics/article.md index 1a4b0c94a..f13127a16 100644 --- a/1-js/02-first-steps/14-function-basics/article.md +++ b/1-js/02-first-steps/14-function-basics/article.md @@ -45,7 +45,7 @@ Este exemplo demonstra claramente um dos principais objetivos das funções: evi Se precisarmos mudar a mensagem ou a maneira que ela é mostrada, basta modificar o código em um só lugar: a função que gera isso. -## Local variables +## Variáveis locais A variable declared inside a function is only visible inside that function.