Skip to content

Objects #32

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

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions 1-js/04-object-basics/01-object/2-hello-object/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ importance: 5

---

# Hello, object
# Hallo Objekt

Write the code, one line for each action:
Schreibe den Code. Für jede Zeile ein Befehl:

1. Create an empty object `user`.
2. Add the property `name` with the value `John`.
3. Add the property `surname` with the value `Smith`.
4. Change the value of the `name` to `Pete`.
5. Remove the property `name` from the object.
1. Kreiere ein leeres Objekt `user`.
2. Füge die Property `name` mit dem Wert `John` hinzu.
3. Füge die Property `surname` mit dem Wert `Smith` hinzu.
4. Ändere den Wert von `name` in `Pete`.
5. Entferne die Property `name` vom Objekt.

2 changes: 1 addition & 1 deletion 1-js/04-object-basics/01-object/3-is-empty/solution.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Just loop over the object and `return false` immediately if there's at least one property.
Man loope über das Objekt und gibt umgehend `return false` an, sodass wenn mindestens eine Property exisitert die Schliefe abgebrochen wird und `true` ausgegeben wird.
6 changes: 3 additions & 3 deletions 1-js/04-object-basics/01-object/3-is-empty/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ importance: 5

---

# Check for emptiness
# Auf Leerstand prüfen

Write the function `isEmpty(obj)` which returns `true` if the object has no properties, `false` otherwise.
Es ist die Funktion `isEmpty(obj)` zu schreiben, die `true` ausgibt wenn das Objekt keine Proerties hat und `false` andernfalls.
Copy link
Contributor

Choose a reason for hiding this comment

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

Schreibe eine Funktion isEmpty(obj), die true zurück gibt falls das Objekt keine Eigenschaften besitzt, ansonsten false


Should work like that:
Es sollt wie folgt funktionieren:

```js
let schedule = {};
Expand Down
8 changes: 4 additions & 4 deletions 1-js/04-object-basics/01-object/4-const-object/solution.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Sure, it works, no problem.
Das funktioniert natürlich ohne weitere Probleme.

The `const` only protects the variable itself from changing.
Die `const` schützt nur die Variabel selbst davon sich zu verändern.

In other words, `user` stores a reference to the object. And it can't be changed. But the content of the object can.
In anderen Worten gesagt speichert `user` eine Referenz zum Objekt. Und diese kann nicht geänder werden, derder Inhalt eines Objekt aber kann.

```js run
const user = {
name: "John"
};

*!*
// works
// funktioniert
user.name = "Pete";
*/!*

Expand Down
6 changes: 3 additions & 3 deletions 1-js/04-object-basics/01-object/4-const-object/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ importance: 5

---

# Constant objects?
# Konstante Objekte?

Is it possible to change an object declared with `const`? What do you think?
Ist es möglich ein Objekt zu ändern, dass mit `const` deklariert wurde?

```js
const user = {
name: "John"
};

*!*
// does it work?
// funktionert das?
user.name = "Pete";
*/!*
```
8 changes: 4 additions & 4 deletions 1-js/04-object-basics/01-object/5-sum-object/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ importance: 5

---

# Sum object properties
# Summierende Properties eines Objekt

We have an object storing salaries of our team:
Wir haben ein Objekt welches die Gehälter unseres Teams speichert:

```js
let salaries = {
Expand All @@ -14,6 +14,6 @@ let salaries = {
}
```

Write the code to sum all salaries and store in the variable `sum`. Should be `390` in the example above.
Man schreibe den Code so, dass alle Gehälter summiert werden und das Ergebnis in der Variabel `sum` abgespeichert wird. Dieses sollte `390` im obigen Beispiel sein.

If `salaries` is empty, then the result must be `0`.
Wenn `salaries` leer sein sollte, so muss das Resultat `0` sein.
14 changes: 7 additions & 7 deletions 1-js/04-object-basics/01-object/8-multiply-numeric/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ importance: 3

---

# Multiply numeric properties by 2
# Numerische Properties mit Faktor 2 multiplizieren

Create a function `multiplyNumeric(obj)` that multiplies all numeric properties of `obj` by `2`.
Man schaffe eine Funktion `multiplyNumeric(obj)`, die alle numerischen Properties von `obj` mit `2` multipliziert.

For instance:
Zum Beispiel:

```js
// before the call
// vor dem Aufruf
let menu = {
width: 200,
height: 300,
Expand All @@ -18,16 +18,16 @@ let menu = {

multiplyNumeric(menu);

// after the call
// nach dem Aufruf
menu = {
width: 400,
height: 600,
title: "My menu"
};
```

Please note that `multiplyNumeric` does not need to return anything. It should modify the object in-place.
Man beachte, dass `multiplyNumeric` nichts auszugeben hat. Es sollte eher das Objekt modifizieren.

P.S. Use `typeof` to check for a number here.
P.S. Man nutze hier `typeof` um nach einer Nummer zu prüfen.


Loading