Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hok7z committed Nov 27, 2024
1 parent af31b0a commit fc6d9b2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Exercises/1-hoisting.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

const fn = null;
const fn = () => {
console.log({ x });
var x = 5;
};

module.exports = { fn };
2 changes: 1 addition & 1 deletion Exercises/2-by-value.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

const inc = null;
const inc = (n) => ++n;

module.exports = { inc };
6 changes: 4 additions & 2 deletions Exercises/3-by-reference.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

const inc = (obj) => {
console.log(obj);
const inc = (num) => {
if (typeof num === 'object') {
num.n++;
}
};

module.exports = { inc };
12 changes: 11 additions & 1 deletion Exercises/4-count-types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
'use strict';

const countTypesInArray = null;
const countTypesInArray = (ArrayOfTypes) => {
const countTypes = {};
for (const item of ArrayOfTypes) {
const type = typeof item;
let count = countTypes[type];
count = count ? count++ : count = 0;
countTypes[type] = count;
};

return countTypes;
};

module.exports = { countTypesInArray };

0 comments on commit fc6d9b2

Please sign in to comment.