◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
15 changes: 7 additions & 8 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,12 @@ importance: 5

---

# Hello, object

Write the code, one line for each action:

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.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function isEmpty(obj) {
for (let key in obj) {
// if the loop has started, there is a property
return false;
}
return true;
Expand Down
7 changes: 3 additions & 4 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

Write the function `isEmpty(obj)` which returns `true` if the object has no properties, `false` otherwise.

Should work like that:

```js
let schedule = {};
Expand All @@ -17,4 +17,3 @@ schedule["8:30"] = "get up";

alert( isEmpty(schedule) ); // false
```

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

We have an object storing salaries of our team:

```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.

If `salaries` is empty, then the result must be `0`.
14 changes: 6 additions & 8 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

Create a function `multiplyNumeric(obj)` that multiplies all numeric properties of `obj` by `2`.

For instance:

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

multiplyNumeric(menu);

// after the call
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.

P.S. Use `typeof` to check for a number here.


Loading
Toggle all file notes Toggle all file annotations