Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions 1-js/04-object-basics/01-object/2-hello-object/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

```js
let user = {};
user.name = "John";
user.surname = "Smith";
user.name = "Pete";
user.name = "Іван";
user.surname = "Сміт";
user.name = "Петро";
delete user.name;
```

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
# Привіт, 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.
1. Створіть порожній об’єкт `user`.
2. Додайте властивість `ім’я` зі значенням `Іван`.
3. Додайте властивість `прізвище` зі значенням `Сміт`.
4. Змініть значення `ім’я` на `Петро`.
5. Видаліть властивість `ім’я` з об’єкта.

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
6 changes: 3 additions & 3 deletions 1-js/04-object-basics/01-object/3-is-empty/_js.view/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
describe("isEmpty", function() {
it("returns true for an empty object", function() {
describe("Порожньо?", function() {
it(`повертає "true" для порожнього об’єкта`, function() {
assert.isTrue(isEmpty({}));
});

it("returns false if a property exists", function() {
it(`повертає "false" якщо властивість існує`, function() {
assert.isFalse(isEmpty({
anything: false
}));
Expand Down
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.
Просто в циклі перебираємо властивості об’єкта і повертаємо `false`, як тільки зустрічаємо властивість.
8 changes: 4 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,18 +2,18 @@ importance: 5

---

# Check for emptiness
# Перевірка на порожнечу

Write the function `isEmpty(obj)` which returns `true` if the object has no properties, `false` otherwise.
Напишіть функцію `isEmpty(obj)` яка повертає `true` якщо об’єкт не має властивості, інакше `false`.

Should work like that:
Має так працювати:

```js
let schedule = {};

alert( isEmpty(schedule) ); // true

schedule["8:30"] = "get up";
schedule["8:30"] = "Вставай";

alert( isEmpty(schedule) ); // false
```
Expand Down
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.
Напишіть код для підсумовування всіх зарплат і збережіть у змінній `sum`. У наведеному вище прикладі має бути `390`.

If `salaries` is empty, then the result must be `0`.
Якщо об’єкт `salaries` порожній, то результат має бути `0`.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
let menu = {
width: 200,
height: 300,
title: "My menu"
title: "Моє меню"
};


function multiplyNumeric(obj) {

/* your code */
/* ваш код */

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
describe("multiplyNumeric", function() {
it("multiplies all numeric properties by 2", function() {
describe("помножимоЧисла", function () {
it("помножити всі числові властивості на 2", function () {
let menu = {
width: 200,
height: 300,
title: "My menu"
title: "Моє меню"
};
let result = multiplyNumeric(menu);
assert.equal(menu.width, 400);
assert.equal(menu.height, 600);
assert.equal(menu.title, "My menu");
assert.equal(menu.title, "Моє меню");
});

it("returns nothing", function() {
assert.isUndefined( multiplyNumeric({}) );
it("нічого не повертає", function () {
assert.isUndefined(multiplyNumeric({}));
});

});
18 changes: 9 additions & 9 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,32 +2,32 @@ importance: 3

---

# Multiply numeric property values by 2
# Помножте числові значення властивостей на 2

Create a function `multiplyNumeric(obj)` that multiplies all numeric property values of `obj` by `2`.
Створіть функцію `multiplyNumeric(obj)`, яка примножує всі числові властивості об’єкта `obj` на `2`.

For instance:
Наприклад:

```js
// before the call
// до виклику функції
let menu = {
width: 200,
height: 300,
title: "My menu"
title: "Моє меню"
};

multiplyNumeric(menu);

// after the call
// після виклику функції
menu = {
width: 400,
height: 600,
title: "My menu"
title: "Моє меню"
};
```

Please note that `multiplyNumeric` does not need to return anything. It should modify the object in-place.
Зверніть увагу, що `multiplyNumeric` не потрібно нічого повертати. Слід безпосередньо змінювати об’єкт.

P.S. Use `typeof` to check for a number here.
P.S. Використовуйте `typeof` для перевірки, що значення властивості числове.


Loading