Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Objects#184

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tarasyyyk merged 11 commits intojavascript-tutorial:masterfromRegnised:master
Aug 15, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
11 commits
Select commitHold shift + click to select a range
a11e2a3
Objects
RegnisedAug 14, 2021
d073b92
Merge branch 'javascript-tutorial:master' into master
RegnisedAug 14, 2021
6f63dff
Update 1-js/04-object-basics/01-object/2-hello-object/task.md
RegnisedAug 15, 2021
690516f
Update 1-js/04-object-basics/01-object/3-is-empty/task.md
RegnisedAug 15, 2021
d1d20f9
Update 1-js/04-object-basics/01-object/8-multiply-numeric/_js.view/te…
RegnisedAug 15, 2021
126b55b
Update 1-js/04-object-basics/01-object/8-multiply-numeric/_js.view/te…
RegnisedAug 15, 2021
1808c2f
Update 1-js/04-object-basics/01-object/article.md
RegnisedAug 15, 2021
b7f4746
Update 1-js/04-object-basics/01-object/article.md
RegnisedAug 15, 2021
c31ff51
Update 1-js/04-object-basics/01-object/2-hello-object/task.md
tarasyyykAug 15, 2021
68d53eb
Update 1-js/04-object-basics/01-object/2-hello-object/task.md
tarasyyykAug 15, 2021
019602e
Update 1-js/04-object-basics/01-object/2-hello-object/task.md
tarasyyykAug 15, 2021
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
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletions1-js/04-object-basics/01-object/2-hello-object/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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.Додайте властивість`name`зі значенням `Іван`.
3.Додайте властивість`surname`зі значенням `Сміт`.
4.Змініть значення`name`на `Петро`.
5.Видаліть властивість`name`з об’єкта.

View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
describe("isEmpty", function() {
it("returnstrue for an empty object", function() {
describe("Порожньо?", function() {
it(`повертає "true" для порожнього об’єкта`, function() {
assert.isTrue(isEmpty({}));
});

it("returnsfalse if a property exists", function() {
it(`повертає "false" якщо властивість існує`, function() {
assert.isFalse(isEmpty({
anything: false
}));
Expand Down
2 changes: 1 addition & 1 deletion1-js/04-object-basics/01-object/3-is-empty/solution.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
Just loop over the object and `returnfalse` immediately if there's at least one property.
Просто в циклі перебираємо властивості об’єкта і повертаємо `false`, як тільки зустрічаємо властивість.
8 changes: 4 additions & 4 deletions1-js/04-object-basics/01-object/3-is-empty/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletions1-js/04-object-basics/01-object/5-sum-object/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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`.
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
let menu = {
width: 200,
height: 300,
title: "My menu"
title: "Моє меню"
};


function multiplyNumeric(obj) {

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

}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
describe("multiplyNumeric", function() {
it("multiplies all numeric properties by 2", function() {
describe("multiplyNumeric", 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 deletions1-js/04-object-basics/01-object/8-multiply-numeric/task.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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

[8]ページ先頭

©2009-2025 Movatter.jp