diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..b58b603f --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/DataTypes.iml b/.idea/DataTypes.iml new file mode 100644 index 00000000..24643cc3 --- /dev/null +++ b/.idea/DataTypes.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 00000000..c363e9d4 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,126 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 00000000..79ee123c --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..03d9549e --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..2445ee8d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Exercises.ua.md b/Exercises.ua.md index 0e1e49b1..d38bdff1 100644 --- a/Exercises.ua.md +++ b/Exercises.ua.md @@ -1,4 +1,4 @@ -# Вправи +x # Вправи ## Скалярні типи та посилання diff --git a/Exercises/1-hoisting.js b/Exercises/1-hoisting.js deleted file mode 100644 index 09200261..00000000 --- a/Exercises/1-hoisting.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -const fn = null; - -module.exports = { fn }; diff --git a/Exercises/1-hoisting.test b/Exercises/1-hoisting.test deleted file mode 100644 index 0fc9394e..00000000 --- a/Exercises/1-hoisting.test +++ /dev/null @@ -1,4 +0,0 @@ -({ - name: 'fn', - length: [20, 150], -}) diff --git a/Exercises/2-by-value.js b/Exercises/2-by-value.js index f576b24e..fb31ca66 100644 --- a/Exercises/2-by-value.js +++ b/Exercises/2-by-value.js @@ -1,5 +1,7 @@ 'use strict'; -const inc = null; + +const inc = (x) => ++x; + module.exports = { inc }; diff --git a/Exercises/3-by-reference.js b/Exercises/3-by-reference.js index 74638ecd..dee9173c 100644 --- a/Exercises/3-by-reference.js +++ b/Exercises/3-by-reference.js @@ -1,7 +1,11 @@ 'use strict'; + + const inc = (obj) => { - console.log(obj); + if (typeof obj === 'object') { + obj.n++; + }; }; module.exports = { inc }; diff --git a/Exercises/4-count-types.js b/Exercises/4-count-types.js index 4c9545af..e6b02fbf 100644 --- a/Exercises/4-count-types.js +++ b/Exercises/4-count-types.js @@ -1,5 +1,14 @@ 'use strict'; -const countTypesInArray = null; +const countTypesInArray = (arr) => { + const typeCount = {}; + for (const item of arr) { + const type = typeof item; + const Counter = typeCount[type] || 0; + typeCount[type] = Counter + 1; + } + return typeCount; +}; + module.exports = { countTypesInArray }; diff --git a/Solutions/4-count-types.js b/Solutions/4-count-types.js index 1f44d764..f9112e9e 100644 --- a/Solutions/4-count-types.js +++ b/Solutions/4-count-types.js @@ -1,4 +1,4 @@ -'use strict'; + 'use strict'; const countTypesInArray = (arr) => { const counters = {};