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

Translated IF statements article and tasks#74

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
meilune merged 17 commits intojavascript-tutorial:masterfrommeilune:master
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
f610c22
Translated If article.md
meiluneJul 26, 2021
06341cd
Translated task.md
meiluneJul 26, 2021
1a1e546
Translated solution.md
meiluneJul 26, 2021
e028ba2
Translated index.html
meiluneJul 26, 2021
f54d212
Translated task.md
meiluneJul 26, 2021
4d8600b
Translated if_else_task2.md
meiluneJul 26, 2021
33d0bd3
Update ifelse_task2.svg
meiluneJul 26, 2021
6ae4a13
Translated ifelse_task2.svg
meiluneJul 26, 2021
3c3491e
Translated ifelse_task2.svg
meiluneJul 26, 2021
b8201d4
Translated ifelse_task2.svg
meiluneJul 26, 2021
105fde0
Translated index.html
meiluneJul 26, 2021
39e8edb
Translated task.md
meiluneJul 26, 2021
26ea426
Translated solution.md
meiluneJul 26, 2021
581e9fb
Translated task.md
meiluneJul 26, 2021
532994a
Translated solution.md
meiluneJul 26, 2021
3c6f0b3
Translated task.md
meiluneJul 26, 2021
4d57c1f
Translated solution.md
meiluneJul 26, 2021
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,12 @@
**Yes, it will.**
**Taip, bus.**

Any string except an empty one (and `"0"`is not empty) becomes `true`in the logical context.
Bet kokia eilutė išskyrus tuščią (o `"0"`nėra tuščia) tampa `true`loginiame kontekste.

We can run and check:
Mes galime paleisti ir patikrinti:

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

6 changes: 3 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,13 @@ importance: 5

---

# if (a string with zero)
# if (eilutė su nuliu)

Will`alert` be shown?
Ar bus parodytas`alert`?

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

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 ofJavaScript?', '');
let value = prompt('Koks yra "oficialusJavaScript pavadinimas?', '');

if (value == 'ECMAScript') {
alert('Right!');
alert('Teisingai!');
} else {
alert("You don't know? ECMAScript!");
alert("Nežinote? ECMAScript!");
}
</script>

Expand Down
6 changes: 3 additions & 3 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,11 +2,11 @@ importance: 2

---

#The name ofJavaScript
# JavaScript pavadinimas

Using the `if..else` construct, write the code which asks: 'What is the "official" name ofJavaScript?'
Naudodami konstruktą `if..else`, parašykite kodą, kuris klausia: 'Koks yra "oficialusJavaScript pavadinimas?'

If the visitor enters"ECMAScript",then output "Right!",otherwise--output: "Didn't know? ECMAScript!"
Jeigu lankytojas įveda"ECMAScript",tada gaunamas "Teisingai!",kitu atveju--gaunamas: "Nežinojote? ECMAScript!"

![](ifelse_task2.svg)

Expand Down
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('Įrašykite skaičių', 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('Įveskite skaičių', 0);

if (value > 0) {
alert( 1 );
Expand Down
12 changes: 6 additions & 6 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@@ -2,14 +2,14 @@ importance: 2

---

#Show the sign
#Parodykite ženklą

Using `if..else`,write the code which gets a number via`prompt`and then shows in `alert`:
Naudodami `if..else`,parašykite kodą, kuris gauna numerį per`prompt`ir tada parodo jį per `alert`:

- `1`,if the value is greater than zero,
- `-1`,if less than zero,
- `0`,if equals zero.
- `1`,jeigu vertė yra didesnė nei nulis,
- `-1`,jeigu mažesnė nei nulis,
- `0`,jeigu lygus nuliui.

In this task we assume that the input is always a number.
Šioje užduotyje mes tariame, kad visada yra įvedamas numeris.

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


```js
let result = (a + b < 4) ? 'Below' : 'Over';
let result = (a + b < 4) ? 'Žemiau' : 'Aukščiau';
```

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

---

#Rewrite 'if'into '?'
#Perrašykite 'if'į '?'

Rewrite this `if`using the conditional operator `'?'`:
Perrašykite šį `if`naudodami sąlygos operatorių `'?'`:

```js
let result;

if (a + b < 4) {
result = 'Below';
result = 'Žemiau';
} else {
result = 'Over';
result = 'Aukščiau';
}
```
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 == 'Darbuotojas') ? 'Labas' :
(login == 'Direktorius') ? 'Sveiki' :
(login == '') ? 'Nėra prisijungimo' :
'';
```

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 '?'
#Perrašykite 'if..else'į '?'

Rewrite `if..else`using multiple ternary operators `'?'`.
Perrašykite `if..else`naudodami daugybinius ternarinius operatorius `'?'`.

For readability, it's recommended to split the code into multiple lines.
Dėl skaitomo rekomenduoja išskirti kodą į kelias eiles.

```js
let message;

if (login == 'Employee') {
message = 'Hello';
} else if (login == 'Director') {
message = 'Greetings';
if (login == 'Darbuotojas') {
message = 'Labas';
} else if (login == 'Direktorius') {
message = 'Sveiki';
} else if (login == '') {
message = 'No login';
message = 'Nėra prisijungimo';
} else {
message = '';
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp