Skip to content

Feature/conditional branching #64

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

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions 1-js/02-first-steps/10-ifelse/1-if-zero-string/solution.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
**Yes, it will.**
**Tak, pokaże się.**

Any string except an empty one (and `"0"` is not empty) becomes `true` in the logical context.
Każdy ciąg znaków z wyjątkiem pustego (a `"0"` nie jest puste) zostaje `true` w kontekście logicznym.

We can run and check:
Możemy uruchomić kod aby sprawdzić:

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

6 changes: 3 additions & 3 deletions 1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ importance: 5

---

# if (a string with zero)
# if (ciąg znaków "0")

Will `alert` be shown?
czy pokaże się `alert`?

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<script>
'use strict';

let value = prompt('What is the "official" name of JavaScript?', '');
let value = prompt('Jaka jest "oficjalna" nazwa JavaScript?', '');

if (value == 'ECMAScript') {
alert('Right!');
alert('Racja!');
} else {
alert("You don't know? ECMAScript!");
alert("Nie wiedziałeś? ECMAScript!");
}
</script>

Expand Down
7 changes: 4 additions & 3 deletions 1-js/02-first-steps/10-ifelse/2-check-standard/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ importance: 2

---

# The name of JavaScript
# Nazwa JavaScript

Using the `if..else` construct, write the code which asks: 'What is the "official" name of JavaScript?'
Używając instrukcji `if..else`, napisz kod który będzie pytał: 'Jaka jest "oficjalna" nazwa JavaScript?'

If the visitor enters "ECMAScript", then output "Right!", otherwise -- output: "Didn't know? ECMAScript!"
Jeżeli odwiedzający wpisze "ECMAScript", wtedy
If the visitor enters "ECMAScript", then zwróć wynik "Racja!", w przeciwnym wypadku -- zwróć wynik: "Nie wiedziałeś? ECMAScript!"

![](ifelse_task2.svg)

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/10-ifelse/3-sign/if_sign/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script>
'use strict';

let value = prompt('Type a number', 0);
let value = prompt('Wpisz liczbę', 0);

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


```js run
let value = prompt('Type a number', 0);
let value = prompt('Wpisz liczbę', 0);

if (value > 0) {
alert( 1 );
Expand Down
12 changes: 6 additions & 6 deletions 1-js/02-first-steps/10-ifelse/3-sign/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ importance: 2

---

# Show the sign
# Pokaż znak

Using `if..else`, write the code which gets a number via `prompt` and then shows in `alert`:
Używając instrukcji `if..else`, napisz kod który pobiera licznę za pomocą metody `prompt` i pokazuje w `alert`:

- `1`, if the value is greater than zero,
- `-1`, if less than zero,
- `0`, if equals zero.
- `1`, Jeżeli wartość jest większa od zera,
- `-1`, jeżeli jest mniejsza od zera,
- `0`, jeżeli jest równa zeru.

In this task we assume that the input is always a number.
W tym zadaniu przyjmujemy że wpisana wartość zawsze jest liczbą.

[demo src="if_sign"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


```js
let result = (a + b < 4) ? 'Below' : 'Over';
let result = (a + b < 4) ? 'Poniżej' : 'Ponad';
```

8 changes: 4 additions & 4 deletions 1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ importance: 5

---

# Rewrite 'if' into '?'
# Przepisz instrukcję `if` na operator warunkowy '?'

Rewrite this `if` using the conditional operator `'?'`:
Przepisz tę instrukcję `if` na operator warunkowy '?'

```js
let result;

if (a + b < 4) {
result = 'Below';
result = 'Poniżej';
} else {
result = 'Over';
result = 'Ponad';
}
```
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@


```js
let message = (login == 'Employee') ? 'Hello' :
(login == 'Director') ? 'Greetings' :
(login == '') ? 'No login' :
let message = (login == 'Pracownik') ? 'Witaj' :
(login == 'Dyrektor') ? 'Pozdrowienia' :
(login == '') ? 'Brak loginu' :
'';
```

16 changes: 8 additions & 8 deletions 1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ importance: 5

---

# Rewrite 'if..else' into '?'
# Przepisz instrukcję `if` na operator warunkowy '?

Rewrite `if..else` using multiple ternary operators `'?'`.
Przepisz instrukcję `if` na używając wielokrotnego operatora warunkowego '?`.

For readability, it's recommended to split the code into multiple lines.
Dla czytelności zalecamy podzielić kod na wiele linii.

```js
let message;

if (login == 'Employee') {
message = 'Hello';
} else if (login == 'Director') {
message = 'Greetings';
if (login == 'Pracownik') {
message = 'Witaj';
} else if (login == 'Dyrektor') {
message = 'Pozdrowienia';
} else if (login == '') {
message = 'No login';
message = 'Brak loginu';
} else {
message = '';
}
Expand Down
Loading