Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Conditional operators: if, '?'#231

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
EzequielCaste merged 37 commits intojavascript-tutorial:masterfromvplentinax:Giorgiosaud-conditional-if
Jun 20, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
37 commits
Select commitHold shift + click to select a range
6941a56
pr-95-Giorgiosaud-correction
vplentinaxJun 5, 2020
e9b7747
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
c72776f
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
1c10a2b
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
643b511
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
26f6448
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
dfe7d40
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
7977b4a
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
e2bb1ec
Update 1-js/02-first-steps/10-ifelse/2-check-standard/task.md
vplentinaxJun 16, 2020
0bb1510
Update 1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md
vplentinaxJun 16, 2020
adefcea
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
10bdedb
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
50ed670
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
fc95df9
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
d6686c0
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
96c3ae7
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
341830f
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
fbbb9c0
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
a29d26e
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
18cac2f
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
51c83f0
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
f3a2697
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
a589360
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
c477d72
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
1848326
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
a76a61c
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
0953da0
Update 1-js/02-first-steps/10-ifelse/article.md
vplentinaxJun 16, 2020
5f314c6
Update 1-js/02-first-steps/10-ifelse/1-if-zero-string/solution.md
EzequielCasteJun 20, 2020
738f22f
Update 1-js/02-first-steps/10-ifelse/1-if-zero-string/solution.md
EzequielCasteJun 20, 2020
ac725a5
Update 1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md
EzequielCasteJun 20, 2020
49f1dfe
Update 1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md
EzequielCasteJun 20, 2020
ffde1eb
Update 1-js/02-first-steps/10-ifelse/2-check-standard/ifelse_task2/in…
EzequielCasteJun 20, 2020
38b09b4
Update 1-js/02-first-steps/10-ifelse/article.md
EzequielCasteJun 20, 2020
36b9977
Update 1-js/02-first-steps/10-ifelse/article.md
EzequielCasteJun 20, 2020
5c02c93
Update 1-js/02-first-steps/10-ifelse/article.md
EzequielCasteJun 20, 2020
22388e4
Update 1-js/02-first-steps/10-ifelse/article.md
EzequielCasteJun 20, 2020
438d1b9
Update 1-js/02-first-steps/10-ifelse/article.md
EzequielCasteJun 20, 2020
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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
**Yes, it will.**
**Sí lo hará.**

Any stringexcept an empty one (and `"0"`is not empty) becomes`true`in the logical context.
Cualquier stringexcepto uno vacío (y `"0"`que no es vacío) se convierte en`true`en un contexto lógico.

We can run and check:
Podemos ejecutar y verificar:

```js run
if ("0") {
alert( 'Hello' );
alert( 'Hola' );
}
```

5 changes: 2 additions & 3 deletions1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,13 +2,12 @@ importance: 5

---

# if (a stringwith zero)
# if (un stringcon cero)

Will`alert` be shown?
Se mostrará el`alert`?

```js
if ("0") {
alert( 'Hello' );
}
```

View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,12 +5,12 @@
<script>
'use strict';

let value = prompt('What is the "official" name of JavaScript?', '');
let value = prompt('¿Cuál es el nombre "oficial" de JavaScript?', '');

if (value == 'ECMAScript') {
alert('Right!');
alert('¡Correcto!');
} else {
alert("You don't know?ECMAScript!");
alert("¿No lo sabes? ¡ECMAScript!");
}
</script>

Expand Down
7 changes: 3 additions & 4 deletions1-js/02-first-steps/10-ifelse/2-check-standard/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,13 +2,12 @@ importance: 2

---

#The name of JavaScript
#El nombre de JavaScript

Using the`if..else` construct, write the code which asks: 'What is the "official" name of JavaScript?'
Usando el constructor`if..else`, escribe el código que pregunta: '¿Cuál es el nombre "oficial" de JavaScript?'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Usando elconstructor`if..else`, escribe el código que pregunta: '¿Cuál es el nombre "oficial" de JavaScript?'
Usando elconstructo`if..else`, escribe el código que pregunta: '¿Cuál es el nombre "oficial" de JavaScript?'


If the visitor enters "ECMAScript",then output "Right!",otherwise--output: "Didn't know?ECMAScript!"
Si el visitador escribe "ECMAScript",Entonces muestras "¡Correcto!",de lo contrario--muestra: "¿No lo sabes? ¡ECMAScript!"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Si elvisitador escribe "ECMAScript",Entonces muestras "¡Correcto!", de lo contrario -- muestra: "¿No lo sabes? ¡ECMAScript!"
Si elvisitante escribe "ECMAScript",entonces muestras "¡Correcto!", de lo contrario -- muestra: "¿No lo sabes? ¡ECMAScript!"


![](ifelse_task2.svg)

[demo src="ifelse_task2"]

View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@
<script>
'use strict';

let value = prompt('Type a number', 0);
let value = prompt('Escribe un número', 0);

if (value > 0) {
alert(1);
Expand Down
2 changes: 1 addition & 1 deletion1-js/02-first-steps/10-ifelse/3-sign/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@


```js run
let value = prompt('Type a number', 0);
let value = prompt('Escribe un número', 0);

if (value > 0) {
alert( 1 );
Expand Down
10 changes: 5 additions & 5 deletions1-js/02-first-steps/10-ifelse/3-sign/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,12 +4,12 @@ importance: 2

# Show the sign
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
#Show the sign
#Muestra el signo


Using`if..else`,write the code which gets anumber via`prompt`and then shows in `alert`:
Usando el constructor`if..else`,escribe un código que obtenga através de un`prompt`un número y entonces muestre en un `alert`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Usando elconstructor`if..else`, escribe un código que obtenga a través de un`prompt` un número y entonces muestre en un`alert`:
Usando elconstructo`if..else`, escribe un código que obtenga a través de un`prompt` un número y entonces muestre en un`alert`:


- `1`,if the value is greater than zero,
- `-1`,if less than zero,
- `0`,if equals zero.
- `1`,si el valor es mayor que cero,
- `-1`,si es menor que cero,
- `0`,si es igual a cero.

In this task we assume that the input is always a number.
En la tarea asumimos que siempre el usuario introduce un número.

[demo src="if_sign"]
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@


```js
result = (a + b < 4) ? 'Below' : 'Over';
result = (a + b < 4) ? 'Debajo' : 'Encima';
```

View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,15 +2,14 @@ importance: 5

---

#Rewrite'if'into '?'
#Reescribe el'if'como '?'

Rewrite this`if`using the ternary operator `'?'`:
Reescriba esta condición`if`usando el operador ternario `'?'`:

```js
if (a + b < 4) {
result = 'Below';
result = 'Debajo';
} else {
result = 'Over';
result = 'Encima';
}
```

View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@


```js
let message = (login == 'Employee') ? 'Hello' :
(login == 'Director') ? 'Greetings' :
(login == '') ? 'No login' :
let message = (login == 'Empleado') ? 'Hola' :
(login == 'Director') ? 'Felicidades' :
(login == '') ? 'Sin sesión' :
'';
```

View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,21 +2,21 @@ importance: 5

---

#Rewrite'if..else'into '?'
#Reescriba el'if..else'con '?'

Rewrite`if..else`using multiple ternary operators`'?'`.
Reescriba el`if..else`utilizando operadores ternarios múltiples`'?'`.

For readability, it's recommended to split the code into multiple lines.
Para legibilidad, es recomendad dividirlo en múltiples lineas de código.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Para legibilidad, es recomendad dividirlo en múltipleslineas de código.
Para legibilidad, es recomendad dividirlo en múltipleslíneas de código.


```js
let message;

if (login == 'Employee') {
message = 'Hello';
if (login == 'Empleado') {
message = 'Hola';
} else if (login == 'Director') {
message = 'Greetings';
message = 'Felicidades';
} else if (login == '') {
message = 'No login';
message = 'Sin sesión';
} else {
message = '';
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp