Skip to content

Commit ae05255

Browse files
committed
Change exercises
1 parent 2a90fac commit ae05255

10 files changed

+46
-16
lines changed

Exercises.en.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ call example: `const obj = { n: 5 }; inc(obj); console.dir(obj);`
2020

2121
## Types
2222

23-
4. Prepare array with values of different type.
24-
5. Prepare collection (object) with type names as keys and `0` as values,
25-
example: `{ number: 0, string: 0 }` and so on for all types.
26-
6. Iterate array with `for..of` loop and increment occurrence counter there
27-
to get collection of types occurrences count for all types in array.
28-
7. Modify this example: remove all keys from initial collection literal and
23+
4. Count different type values in array.
24+
25+
- Prepare array with values of different types, for example:
26+
`[true, 'hello', 5, 12, -200, false, false, 'word']` but preferably
27+
longer and more varied.
28+
- Prepare collection-object (hash) with type names as keys and `0` as values,
29+
for example: `{ number: 0, string: 0, boolean: 0 }`
30+
- Iterate array with `for..of` loop and increment occurrence counter there to
31+
get collection of types occurrences count for all types in array.
32+
- Modify this example: remove all keys from initial collection literal and
2933
add all keys dynamically from the loop.

Exercises.ru.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020

2121
## Типы объектов
2222

23-
4. Создайте массив, содержащий названия различных типов данных, в качестве элементов,
24-
пример: `['number', 'string', 'number']`
25-
5. Создайте объект-коллекцию с именами типов в виде ключей и `0` в качестве значения,
26-
пример: `{ number: 0, string: 0 }` и так далее для всех типов данных.
27-
6. Пройдитесь по массиву циклом `for..of` и для каждого элемента массива, увеличивайте
28-
соответствующее значение в объекте-коллекции.
29-
7. Измените пример: удалите все ключи из начальной коллекции и добавляйте их
30-
динамически используя цикл.
23+
4. Подсчет элементов различных типов в массиве.
24+
25+
- Создайте исходный массив, содержащий значения различных типов, в качестве
26+
элементов, например: `[true, 'hello', 5, 12, -200, false, false, 'word']`
27+
но желательно более длинный и разнообразный.
28+
- Создайте объект-коллекцию (хеш) с именами типов в виде ключей и `0` в качестве
29+
значения, например: `{ number: 0, string: 0, boolean: 0 }`
30+
- Пройдитесь по массиву циклом `for..of` и для каждого элемента массива,
31+
увеличивайте соответствующее значение в объекте-коллекции.
32+
- Измените пример: удалите все ключи из начальной коллекции и добавляйте их
33+
динамически в цикле.

Exercises/1-hoisting.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
const fn = null;
4+
5+
module.exports = { fn };

Exercises/1-hoisting.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
({
2+
name: 'fn',
3+
length: [20, 150]
4+
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

3-
const inc = undefined;
3+
const inc = null;
44

55
module.exports = { inc };
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

3-
const inc = undefined;
3+
const inc = null;
44

55
module.exports = { inc };
File renamed without changes.

Exercises/4-count-types.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
const countTypesInArray = null;
4+
5+
module.exports = { countTypesInArray };

Exercises/4-count-types.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
({
2+
name: 'countTypesInArray',
3+
length: [100, 200],
4+
cases: [
5+
[[true, true, false], { 'boolean': 3 }],
6+
[[1, true, 'hello'], { 'number': 1, 'boolean': 1, string: 1 }],
7+
[[1, 2, true, false, 'a', 'b'], { 'number': 2, 'boolean': 2, string: 2 }],
8+
]
9+
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy