- Notifications
You must be signed in to change notification settings - Fork111
Logical operators#401
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
Merged
nazarepiedady merged 14 commits intojavascript-tutorial:masterfromjonnathan-ls:logical-operatorsDec 23, 2023
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
14 commits Select commitHold shift + click to select a range
8a9997d
Merge pull request #1 from javascript-tutorial/master
Mr-Saxobeatae5c0ae
Create article-pt.md
Mr-Saxobeatba126b4
Finish translating the OR part
Mr-Saxobeat240ce48
Fix identation
Mr-Saxobeat7797c95
Finish a simple translation
Mr-Saxobeat8ee735b
Finish portuguese article
Mr-Saxobeate5a21be
Replace the english article by the portuguese
Mr-Saxobeat7a982ad
Delete empty lines at the end of article
Mr-Saxobeat02f7bd3
Translate the tasks and solutions
Mr-Saxobeat34ce10e
refactor: changes correction suggestions according to PR number 56 an…
jonnathan-ls67cb941
Merge branch 'master' of https://github.com/jonnathan-ls/pt.javascrip…
jonnathan-lsa2483bf
refactor: translate words from svg file in article 'logical operators'
jonnathan-lsef863ab
Update article.md
odsantose645c6c
Merge branch 'master' of https://github.com/javascript-tutorial/pt.ja…
jonnathan-lsFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
3 changes: 1 addition & 2 deletions1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
A resposta é `2`,pois é o primeiro valor verdadeiro. | ||
```js run | ||
alert( null || 2 || undefined ); | ||
``` | ||
5 changes: 2 additions & 3 deletions1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,11 +2,10 @@ importance: 5 | ||
--- | ||
#Qual o resultado do *OR*? | ||
Qual é a saída do código abaixo? | ||
```js | ||
alert( null || 2 || undefined ); | ||
``` | ||
12 changes: 6 additions & 6 deletions1-js/02-first-steps/11-logical-operators/2-alert-or/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
A resposta: primeiro `1`,depois `2`. | ||
```js run | ||
alert( alert(1) || 2 || alert(3) ); | ||
``` | ||
Ao chamar`alert`não é retornado nenhum valor. Ou seja, é retornado `undefined`. | ||
1.O primeiro *OR* `||`avalia o operando da esquerda`alert(1)`.Que mostra a primeira mensagem com `1`. | ||
2.O `alert`retorna `undefined`,então *OR* vai ao segundo operando procurando por um valor verdadeiro. | ||
3.O segundo operando `2`é verdadeiro, então a execução é interrompida, `2`é retornado e, é mostrado pelo `alert` externo. | ||
Não haverá`3`,pois a execução não chega a `alert(3)`. |
5 changes: 2 additions & 3 deletions1-js/02-first-steps/11-logical-operators/2-alert-or/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
Resposta: `null`,pois é o primeiro valor falso da lista. | ||
```js run | ||
alert(1 && null && 2); | ||
``` | ||
5 changes: 2 additions & 3 deletions1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,11 +2,10 @@ importance: 5 | ||
--- | ||
#Qual o resultado de *AND*? | ||
O que este código irá mostrar? | ||
```js | ||
alert( 1 && null && 2 ); | ||
``` | ||
7 changes: 3 additions & 4 deletions1-js/02-first-steps/11-logical-operators/4-alert-and/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
Resposta: `1`,e depois `undefined`. | ||
```js run | ||
alert( alert(1) && alert(2) ); | ||
``` | ||
A chamada de `alert` retorna `undefined` (apenas mostra uma mensagem, então não existe nenhum retorno significativo). | ||
Por causa disso, `&&` avalia o operando à esquerda (mostra `1`), e imediatamente interrompe, pois, `undefined` é um valor falso. *AND* `&&` procura por um valor falso e o retorna, então está feito. |
5 changes: 2 additions & 3 deletions1-js/02-first-steps/11-logical-operators/4-alert-and/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions1-js/02-first-steps/11-logical-operators/5-alert-and-or/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
Resposta: `3`. | ||
```js run | ||
alert( null || 2 && 3 || 4 ); | ||
``` | ||
A precedência de *AND* `&&`é maior que *OR*`||`. Então ele é executado primeiro. | ||
O resultado de `2 && 3 = 3`,então a expressão se torna: | ||
``` | ||
null || 3 || 4 | ||
``` | ||
Agora o resultado é o primeiro valor verdadeiro: `3`. |
5 changes: 2 additions & 3 deletions1-js/02-first-steps/11-logical-operators/5-alert-and-or/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,11 +2,10 @@ importance: 5 | ||
--- | ||
#O resultado de *OR* *AND* *OR* | ||
Qual será o resultado? | ||
```js | ||
alert( null || 2 && 3 || 4 ); | ||
``` | ||
1 change: 0 additions & 1 deletion1-js/02-first-steps/11-logical-operators/6-check-if-in-range/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,4 +3,3 @@ | ||
```js | ||
if (age >= 14 && age <= 90) | ||
``` | ||
6 changes: 3 additions & 3 deletions1-js/02-first-steps/11-logical-operators/6-check-if-in-range/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions1-js/02-first-steps/11-logical-operators/7-check-if-out-range/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
A primeira variação: | ||
```js | ||
if (!(age >= 14 && age <= 90)) | ||
``` | ||
A segunda variação: | ||
```js | ||
if (age < 14 || age > 90) | ||
``` | ||
6 changes: 3 additions & 3 deletions1-js/02-first-steps/11-logical-operators/7-check-if-out-range/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
25 changes: 12 additions & 13 deletions1-js/02-first-steps/11-logical-operators/8-if-question/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
Resposta: o primeiro e o terceiro serão executados. | ||
Detalhes: | ||
```js run | ||
//Executa. | ||
//O resultado de -1 || 0 = -1,verdadeiro. | ||
if (-1 || 0) alert( 'primeiro' ); | ||
//Não executa. | ||
// -1 && 0 = 0,falso | ||
if (-1 && 0) alert( 'segundo' ); | ||
//Executa. | ||
//O operador&&tem precedência maior que || | ||
//então -1&& 1executa primeiro, nos dando o encadeamento: | ||
// null || -1 && 1 -> null || 1 -> 1 | ||
if (null || -1 && 1) alert( 'terceiro' ); | ||
``` | ||
13 changes: 6 additions & 7 deletions1-js/02-first-steps/11-logical-operators/8-if-question/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions1-js/02-first-steps/11-logical-operators/9-check-login/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
```js run demo | ||
let userName = prompt("Quem está aí?", ''); | ||
if (userName === 'Admin') { | ||
let pass = prompt('Senha?', ''); | ||
if (pass === 'TheMaster') { | ||
alert( 'Bem vindo!' ); | ||
} else if (pass === '' || pass === null) { | ||
alert( 'Cancelado.' ); | ||
} else { | ||
alert( 'Senha incorreta.' ); | ||
} | ||
} else if (userName === '' || userName === null) { | ||
alert( 'Cancelado' ); | ||
} else { | ||
alert( "Eu não conheço você." ); | ||
} | ||
``` | ||
Noteas indentações verticais dentro dos blocos de`if`s. Tecnicamente, elas não são necessárias, mas tornam o código mais legível. |
20 changes: 10 additions & 10 deletions1-js/02-first-steps/11-logical-operators/9-check-login/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.