Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traducao use-the-conditional-ternary-operator #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
id: 587d7b7e367417b2b2512b24
title: Use the Conditional (Ternary) Operator
title: Use o Operador Condicional (Ternário)
challengeType: 1
forumTopicId: 301181
dashedName: use-the-conditional-ternary-operator
---

# --description--

The <dfn>conditional operator</dfn>, also called the <dfn>ternary operator</dfn>, can be used as a one line if-else expression.
O <dfn>operador condicional</dfn>, também chamado de <dfn>operador ternário</dfn>, pode ser usado como uma expressão if-else de uma linha.

The syntax is:
A sintaxe é:

`condition ? expression-if-true : expression-if-false;`

The following function uses an if-else statement to check a condition:
A função a seguir usa uma instrução if-else para verificar uma condição:

```js
function findGreater(a, b) {
Expand All @@ -27,7 +27,7 @@ function findGreater(a, b) {
}
```

This can be re-written using the `conditional operator`:
Isso pode ser reescrito usando o `operador condicional`:

```js
function findGreater(a, b) {
Expand All @@ -37,29 +37,29 @@ function findGreater(a, b) {

# --instructions--

Use the `conditional operator` in the `checkEqual` function to check if two numbers are equal or not. The function should return either "Equal" or "Not Equal".
Use o `operador condicional` na função `checkEqual` para verificar se dois números são iguais ou não. A função deve retornar "Equal" ou "Not Equal".

# --hints--

`checkEqual` should use the `conditional operator`
`checkEqual` deve usar o `operador condicional`

```js
assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?/.test(code));
```

`checkEqual(1, 2)` should return "Not Equal"
`checkEqual(1, 2)` deve retornar "Not Equal"

```js
assert(checkEqual(1, 2) === 'Not Equal');
```

`checkEqual(1, 1)` should return "Equal"
`checkEqual(1, 1)` deve retornar "Equal"

```js
assert(checkEqual(1, 1) === 'Equal');
```

`checkEqual(1, -1)` should return "Not Equal"
`checkEqual(1, -1)` deve retornar "Not Equal"

```js
assert(checkEqual(1, -1) === 'Not Equal');
Expand Down