Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = () => {
const someData = undefined;
return someData;
};

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

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

const a = 5;
const b = inc(a);

console.log({ a, b });

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

const obj = { n: 5 };

const inc = (obj) => {
console.log(obj);
obj.n++;
};

inc(obj);

console.dir(obj);

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 arr = [true, 'hello', 5, 12, -200, false, false, 'word'];

const countTypesInArray = (arr) => {
const conters = {};
for (const el of arr) {
const type = typeof el;
const count = conters[type] || 0;
conters[type] = count + 1;
}
return conters;
};

module.exports = { countTypesInArray };
Loading