diff --git a/Exercises/1-hoisting.js b/Exercises/1-hoisting.js index 0920026..7a69046 100644 --- a/Exercises/1-hoisting.js +++ b/Exercises/1-hoisting.js @@ -1,5 +1,7 @@ 'use strict'; -const fn = null; +const fn = () => { + const a = 5; +}; module.exports = { fn }; diff --git a/Exercises/2-by-value.js b/Exercises/2-by-value.js index f576b24..e7652d5 100644 --- a/Exercises/2-by-value.js +++ b/Exercises/2-by-value.js @@ -1,5 +1,5 @@ 'use strict'; -const inc = null; +const inc = a => ++a; module.exports = { inc }; diff --git a/Exercises/3-by-reference.js b/Exercises/3-by-reference.js index f576b24..be65287 100644 --- a/Exercises/3-by-reference.js +++ b/Exercises/3-by-reference.js @@ -1,5 +1,9 @@ 'use strict'; -const inc = null; +const inc = num => { + if (typeof num === 'object') { + ++num.n; + } +}; module.exports = { inc }; diff --git a/Exercises/4-count-types.js b/Exercises/4-count-types.js index 4c9545a..b67b373 100644 --- a/Exercises/4-count-types.js +++ b/Exercises/4-count-types.js @@ -1,5 +1,13 @@ 'use strict'; -const countTypesInArray = null; +const countTypesInArray = array => { + const obj = {}; + array.forEach(item => { + const type = typeof item; + const count = obj[type] || 0; + obj[type] = count + 1; + }); + return obj; +}; module.exports = { countTypesInArray }; diff --git a/package-lock.json b/package-lock.json index 33eaeb2..f235cea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -576,7 +576,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { - "minimist": "1.2.5" + "minimist": "0.0.8" }, "dependencies": { "minimist": {