Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f3e240f
Update task.md
SirCodewright Mar 17, 2020
be76b2d
Update article.md
SirCodewright Mar 17, 2020
e5ca2f2
First draft
SirCodewright Mar 17, 2020
f96d32c
Update solution.md
SirCodewright Mar 17, 2020
2d243ad
Update task.md
SirCodewright Mar 17, 2020
4c51d03
Update solution.md
SirCodewright Mar 17, 2020
b7aa5b6
Update solution.md
SirCodewright Mar 17, 2020
b8067c6
Update task.md
SirCodewright Mar 17, 2020
b0d0d01
Update solution.md
SirCodewright Mar 17, 2020
b98325f
Update solution.md
SirCodewright Mar 17, 2020
e449c42
Improved wording
SirCodewright Mar 17, 2020
bec3118
Update task.md
SirCodewright Mar 17, 2020
4a6af62
Update solution.md
SirCodewright Mar 17, 2020
f4c2547
Update task.md
SirCodewright Mar 17, 2020
fe43dbf
Update solution.md
SirCodewright Mar 17, 2020
d69a0b4
Update task.md
SirCodewright Mar 17, 2020
160179e
Update task.md
SirCodewright Mar 17, 2020
c07bd39
Update task.md
SirCodewright Mar 17, 2020
a538cff
Update solution.md
SirCodewright Mar 17, 2020
6971d47
Update task.md
SirCodewright Mar 17, 2020
b531c02
Update solution.md
SirCodewright Mar 17, 2020
ed48368
Update task.md
SirCodewright Mar 17, 2020
3be9e1c
Update solution.md
SirCodewright Mar 17, 2020
b49ff9f
Update task.md
SirCodewright Mar 17, 2020
34990ad
Update ifelse_task.svg
SirCodewright Mar 17, 2020
1155f22
Update ifelse_task.svg
SirCodewright Mar 17, 2020
f1e7c21
Update ifelse_task.svg
SirCodewright Mar 17, 2020
9117c09
Update ifelse_task.svg
SirCodewright Mar 17, 2020
6c20930
Update ifelse_task.svg
SirCodewright Mar 17, 2020
fc8f68b
Update ifelse_task.svg
SirCodewright Mar 17, 2020
45a4c39
Update ifelse_task.svg
SirCodewright Mar 17, 2020
a712245
Review issues / update #1
SirCodewright Apr 5, 2020
3fc6693
Review issues / update #2
SirCodewright Apr 5, 2020
4fe03cb
Review issues / update #1
SirCodewright Apr 5, 2020
fa2d1aa
Review issues / update #4
SirCodewright Apr 5, 2020
d2a7712
Review issues / update #5
SirCodewright Apr 5, 2020
4f9a965
Review issues / update #6
SirCodewright Apr 5, 2020
33f1edb
Review issues / update #7
SirCodewright Apr 5, 2020
087c67e
Merge branch 'master' into master
SirCodewright Apr 5, 2020
ec4644f
Review round #2 200420 / update #1
SirCodewright Apr 21, 2020
e8f1d7d
Review round #2 200420 / update #2
SirCodewright Apr 21, 2020
360200d
Review round #2 200420 / update #3
SirCodewright Apr 21, 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The answer is `2`, that's the first truthy value.
Die Antwort lautet `2`, das ist der erste effektiv wahre Wert.

```js run
alert( null || 2 || undefined );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 5

---

# What's the result of OR?
# Welches Ergebnis liefert ODER ?

What is the code below going to output?
Was gibt der untenstehende Code aus ?

```js
alert( null || 2 || undefined );
Expand Down
12 changes: 6 additions & 6 deletions 1-js/02-first-steps/11-logical-operators/2-alert-or/solution.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
The answer: first `1`, then `2`.
Antwort: zuerst `1`, dann `2`.

```js run
alert( alert(1) || 2 || alert(3) );
```

The call to `alert` does not return a value. Or, in other words, it returns `undefined`.
Der Aufruf von `alert` liefert keinen Wert zurück. Genauer formuliert liefert er `undefined`.

1. The first OR `||` evaluates its left operand `alert(1)`. That shows the first message with `1`.
2. The `alert` returns `undefined`, so OR goes on to the second operand searching for a truthy value.
3. The second operand `2` is truthy, so the execution is halted, `2` is returned and then shown by the outer alert.
1. Das erste ODER `||` wertet seinen linken Operanden `alert(1)` aus. Das führt zur Anzeige der ersten Nachricht `1`.
2. Der Aufruf von `alert` liefert `undefined`, also setzt ODER die Suche nach einen effektiv wahren Wert mit dem zweiten Operanden fort.
3. Der zweite Operand `2` ist effektiv wahr, die Ausführung wird gestoppt, `2` wird zurückgegeben und mittels des äußeren `alert` angezeigt.

There will be no `3`, because the evaluation does not reach `alert(3)`.
`3` wird nicht angezeigt, da die Auswertung `alert(3)` nicht erreicht.
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/11-logical-operators/2-alert-or/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 3

---

# What's the result of OR'ed alerts?
# Was ergeben mit ODER verknüpfte `alert`-Aufrufe ?

What will the code below output?
Was gibt der untenstehende Code aus?

```js
alert( alert(1) || 2 || alert(3) );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The answer: `null`, because it's the first falsy value from the list.
Antwort: `null`, denn das ist der erste effektiv nicht wahre Wert aus der Liste.

```js run
alert( 1 && null && 2 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 5

---

# What is the result of AND?
# Was ist das Ergebnis von UND?

What is this code going to show?
Was zeigt der untenstehende Code an?

```js
alert( 1 && null && 2 );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
The answer: `1`, and then `undefined`.
Antwort: `1`, anschließend `undefined`.

```js run
alert( alert(1) && alert(2) );
```

The call to `alert` returns `undefined` (it just shows a message, so there's no meaningful return).
Der Aufruf von `alert` gibt `undefined` zurück (Die Funktion gibt nur eine Nachricht aus, ohne Rückgabewert).

Because of that, `&&` evaluates the left operand (outputs `1`), and immediately stops, because `undefined` is a falsy value. And `&&` looks for a falsy value and returns it, so it's done.
Deswegen wertet `&&` den linken Operanden aus (Ausgabe von `1`) und terminiert unmittelbar, da `undefined` ein effektiv nicht wahrer Wert ist. `&&` wiederum sucht nach einem effektiv nicht wahren Wert und gibt ihn zurück, das beendet somit die Auswertung.

4 changes: 2 additions & 2 deletions 1-js/02-first-steps/11-logical-operators/4-alert-and/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 3

---

# What is the result of AND'ed alerts?
# Was ist das Ergebnis mit UND verknüpfter `alert`-Aufrufe?

What will this code show?
Was gibt untenstehender Code aus?

```js
alert( alert(1) && alert(2) );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
The answer: `3`.
Antwort: `3`.

```js run
alert( null || 2 && 3 || 4 );
```

The precedence of AND `&&` is higher than `||`, so it executes first.
Die Präzedenz von UND `&&` ist höher als die von `||`, deswegen wird UND zuerst ausgeführt.

The result of `2 && 3 = 3`, so the expression becomes:
Das Ergebnis von `2 && 3` lautet `3`, damit wird der Ausdruck zu:

```
null || 3 || 4
```

Now the result is the first truthy value: `3`.
Das Ergebnis ist dann der erste effektiv wahre Wert: `3`.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 5

---

# The result of OR AND OR
# Das Ergebnis von ODER UND ODER

What will the result be?
Was ist das Ergebnis?

```js
alert( null || 2 && 3 || 4 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ importance: 3

---

# Check the range between
# Bereichsprüfung (positiv)

Write an "if" condition to check that `age` is between `14` and `90` inclusively.

"Inclusively" means that `age` can reach the edges `14` or `90`.
Schreibe die Bedingung für eine Fallunterscheidung mit `if` um zu prüfen, daß `age` zwischen `14` and `90` liegt (Grenzen inklusive, `age` kann also die Werte `14` und `90` annehmen).
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
The first variant:
Erste Variante:

```js
if (!(age >= 14 && age <= 90))
```

The second variant:
Zweite Variante:

```js
if (age < 14 || age > 90)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ importance: 3

---

# Check the range outside
# Bereichsprüfung (negativ)

Write an `if` condition to check that `age` is NOT between 14 and 90 inclusively.
Schreibe die Bedingung für eine Fallunterscheidung mit `if` um zu prüfen, dass `age` NICHT zwischen `14` und `90` liegt (Grenzen inklusive).

Create two variants: the first one using NOT `!`, the second one -- without it.
Formuliere 2 Varianten, die Erste mit NICHT `!`, die Zweite -- ohne.
23 changes: 11 additions & 12 deletions 1-js/02-first-steps/11-logical-operators/8-if-question/solution.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
The answer: the first and the third will execute.
Antwort: Erster und dritter Aufruf werden ausgeführt.

Details:

```js run
// Runs.
// The result of -1 || 0 = -1, truthy
if (-1 || 0) alert( 'first' );
// Ausgeführt.
// Das Resultat von -1 || 0 = -1, effektiv wahr
if (-1 || 0) alert( 'Erster' );

// Doesn't run
// -1 && 0 = 0, falsy
if (-1 && 0) alert( 'second' );
// Nicht ausgeführt
// -1 && 0 = 0, effektiv nicht wahr
if (-1 && 0) alert( 'Zweiter' );

// Executes
// Operator && has a higher precedence than ||
// so -1 && 1 executes first, giving us the chain:
// Ausgeführt
// Operator && hat höhere Präzedenz als ||,
// damit wird -1 && 1 zuerst ausgewertet, mit der Auswertereihung:
// null || -1 && 1 -> null || 1 -> 1
if (null || -1 && 1) alert( 'third' );
if (null || -1 && 1) alert( 'Dritter' );
```

12 changes: 6 additions & 6 deletions 1-js/02-first-steps/11-logical-operators/8-if-question/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ importance: 5

---

# A question about "if"
# Eine Frage zu "if"

Which of these `alert`s are going to execute?
Welche der fogenden `alert`-Aufrufe werden ausgeführt?

What will the results of the expressions be inside `if(...)`?
Was sind die Ergebnisse der Ausdrücke in den Bedingungen `if(...)`?

```js
if (-1 || 0) alert( 'first' );
if (-1 && 0) alert( 'second' );
if (null || -1 && 1) alert( 'third' );
if (-1 || 0) alert( 'Erster' );
if (-1 && 0) alert( 'Zweiter' );
if (null || -1 && 1) alert( 'Dritter' );
```

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading