diff --git a/Exercises/1-hoisting.js b/Exercises/1-hoisting.js index 0920026..ab6ab6b 100644 --- a/Exercises/1-hoisting.js +++ b/Exercises/1-hoisting.js @@ -1,5 +1,8 @@ 'use strict'; -const fn = null; +const fn = function raising() { + const variable = 'Hello'; + console.log(variable); +}; module.exports = { fn }; diff --git a/Exercises/2-by-value.js b/Exercises/2-by-value.js index f576b24..80e623e 100644 --- a/Exercises/2-by-value.js +++ b/Exercises/2-by-value.js @@ -1,5 +1,9 @@ 'use strict'; -const inc = null; +const inc = (x) => ++x; + +// function inc(n) { +// return n+1; +// } module.exports = { inc }; diff --git a/Exercises/3-by-reference.js b/Exercises/3-by-reference.js index 74638ec..c7e21a3 100644 --- a/Exercises/3-by-reference.js +++ b/Exercises/3-by-reference.js @@ -1,7 +1,15 @@ 'use strict'; -const inc = (obj) => { - console.log(obj); +const inc = function(obj) { + obj.n += 1; }; +// function inc(num) { +// if (num && typeof num.n === 'number') { +// num.n += 1; +// } else { +// throw new Error("Invalid input: Object must have a numeric 'n' field"); +// } +// } + module.exports = { inc }; diff --git a/Exercises/4-count-types.js b/Exercises/4-count-types.js index 4c9545a..ff1faae 100644 --- a/Exercises/4-count-types.js +++ b/Exercises/4-count-types.js @@ -1,5 +1,12 @@ 'use strict'; -const countTypesInArray = null; +function countTypesInArray(arr) { + const result = {}; + for (const item of arr) { + const type = typeof item; + result[type] = (result[type] || 0) + 1; + } + return result; +} module.exports = { countTypesInArray }; 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