Skip to content

Commit 4496e70

Browse files
authored
Update article.md
1 parent 261b01f commit 4496e70

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

1-js/02-first-steps/14-function-basics/article.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
# Functions
1+
# Funções
22

3-
Quite often we need to perform a similar action in many places of the script.
3+
Muitas vezes nós precisamos realizar uma ação semelhante em muitos lugares do script.
44

5-
For example, we need to show a nice-looking message when a visitor logs in, logs out and maybe somewhere else.
5+
Por exemplo, precisamos mostrar uma boa mensagem quando um usuário efetua login, efetua logout e talvez em outro lugar.
66

7-
Functions are the main "building blocks" of the program. They allow the code to be called many times without repetition.
7+
Funções são os principais "building blocks" do programa. Elas permitem que o código sejam chamados muitas vezes sem repetição.
88

9-
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.
9+
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.
1010

1111
## Function Declaration
1212

13-
To create a function we can use a *function declaration*.
13+
Para criarmos uma função podemos usar uma *function declaration*.
1414

15-
It looks like this:
15+
Se parece assim:
1616

1717
```js
1818
function showMessage() {
19-
alert( 'Hello everyone!' );
19+
alert( 'Olá a todos!' );
2020
}
2121
```
2222

23-
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.
23+
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.
2424

2525
![](function_basics.png)
2626

27-
Our new function can be called by its name: `showMessage()`.
27+
Nossa nova função pode ser chamada pelo seu nome: `showMessage()`.
2828

29-
For instance:
29+
Por exemplo:
3030

3131
```js run
3232
function showMessage() {
33-
alert( 'Hello everyone!' );
33+
alert( 'Olá a todos!' );
3434
}
3535

3636
*!*
@@ -39,11 +39,11 @@ showMessage();
3939
*/!*
4040
```
4141

42-
The call `showMessage()` executes the code of the function. Here we will see the message two times.
42+
A chamada `showMessage()` executa o código da função. Aqui vemos a mensagem duas vezes.
4343

44-
This example clearly demonstrates one of the main purposes of functions: to avoid code duplication.
44+
Este exemplo demonstra claramente um dos principais objetivos das funções: evitar código duplicado.
4545

46-
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.
46+
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.
4747

4848
## Local variables
4949

0 commit comments

Comments
 (0)