Skip to content

Commit f21e0e5

Browse files
committed
Put tasks into js files
1 parent f4f084d commit f21e0e5

File tree

11 files changed

+59
-3
lines changed

11 files changed

+59
-3
lines changed

Exercises.ua.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
## Об'єкти
3333

3434
7. Виконайте такі пункти всередині функції `fn` (див. приклад: `7-objects.js`)
35-
- Створіть об'єкт з одним полем 'name' і запишіть посилання на нього його в константу.
36-
- Створіть об'єкт з одним полем `name` і запишіть посилання на нього його в змінну.
37-
- Спробуйте змінити поле `name` в обох об'єктів.
35+
- Створіть об'єкт з одним полем `name` і запишіть посилання на нього в константу.
36+
- Створіть об'єкт з одним полем `name` і запишіть посилання на нього в змінну.
37+
- Спробуйте змінити значення поля `name` в обох об'єктів.
3838
- Спробуйте записати посилання на інший об'єкт в обидва ідентифікатори.
3939
- Поясніть поведінку коду та залиште лише робочий код.
4040
8. Реалізуйте функцію 'createUser' з сигнатурою `createUser(name: string, city: string): object`. Приклад виклику: `createUser('Marcus Aurelius', 'Roma')` функція повинна повернути об'єкт `{ name: 'Marcus Aurelius', city: 'Roma' }`

Exercises/1-let.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
// Define variable to store your name as a string
4+
35
let name = undefined;
46

57
module.exports = { name };

Exercises/2-const.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
// Define constant to store your birth year as a number
4+
35
const year = undefined;
46

57
module.exports = { year };

Exercises/3-hello.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
// Prepare function to print greeting with single argument
4+
35
const hello = null;
46

57
module.exports = { hello };

Exercises/4-range.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use strict';
22

3+
// Implement function `range(start: number, end: number): array` returning
4+
// array with all numbers from the range [15, 30] including endpoints
5+
36
const range = null;
47

58
module.exports = { range };

Exercises/5-range-odd.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use strict';
22

3+
// Implement function `rangeOdd(start: number, end: number)` returning
4+
// array with all odd numbers from the range [15, 30] including endpoints
5+
36
const rangeOdd = null;
47

58
module.exports = { rangeOdd };

Exercises/6-calculate.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
'use strict';
22

3+
/* Call function from function in loop
4+
- Implement function `average` with signature
5+
`average(a: number, b: number): number`
6+
calculating average (arithmetic mean).
7+
- Implement function `square` with signature
8+
`square(x: number): number` calculating square of x.
9+
- Implement function `cube` with signature
10+
`cube(x: number): number` calculating cube of x.
11+
- Call `square` and `cube` in loop 0 to 9, pass results
12+
to function `average` on each iteration.
13+
Add calculation results to array and return this array
14+
from function `calculate`.
15+
16+
Call functions `square` and `cube` in loop, then pass their
17+
results to function `average`. Print what `average` returns. */
18+
319
const square = null;
420

521
const cube = null;

Exercises/7-objects.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict';
22

3+
/* Do following tasks inside function `fn` (see stub: `7-objects.js`)
4+
- Define constant object with single field `name`.
5+
- Define variable object with single field `name`.
6+
- Try to change field `name`.
7+
- Try to assign other object to both identifiers.
8+
- Explain script behaviour. */
9+
310
const fn = null;
411

512
module.exports = { fn };

Exercises/8-create.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
'use strict';
22

3+
/* Implement function `createUser` with signature
4+
`createUser(name: string, city: string): object`.
5+
Example: `createUser('Marcus Aurelius', 'Roma')`
6+
will return object `{ name: 'Marcus Aurelius', city: 'Roma' }` */
7+
38
const createUser = null;
49

510
module.exports = { createUser };

Exercises/9-array.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
'use strict';
22

3+
/* Collections: Array, Hash (Object)
4+
5+
Implement phone book using array of records.
6+
- Define Array of objects with two fields: `name` and `phone`.
7+
Object example: `{ name: 'Marcus Aurelius', phone: '+380445554433' }`.
8+
- Implement function `findPhoneByName` with signature
9+
`findPhoneByName(name: string): string`. Returning phone from that object
10+
where field `name` equals argument `name`. Use `for` loop for this search. */
11+
312
const phonebook = null;
413

514
const findPhoneByName = null;

Exercises/a-hash.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
'use strict';
22

3+
/* 10. Implement phone book using hash (also known as `object`).
4+
- Define hash with `key` contains `name` (from previous example) and `value`
5+
contains `phone`.
6+
- Implement function `findPhoneByName` with signature
7+
`findPhoneByName(name: string): string`. Returning phone from hash/object.
8+
Use `hash[key]` to find needed phone. */
9+
310
const phonebook = null;
411

512
const findPhoneByName = null;

0 commit comments

Comments
 (0)