Skip to content

Commit fc6d9b2

Browse files
author
hok7z
committed
First commit
1 parent af31b0a commit fc6d9b2

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

Exercises/1-hoisting.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use strict';
22

3-
const fn = null;
3+
const fn = () => {
4+
console.log({ x });
5+
var x = 5;
6+
};
47

58
module.exports = { fn };

Exercises/2-by-value.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
22

3-
const inc = null;
3+
const inc = (n) => ++n;
44

55
module.exports = { inc };

Exercises/3-by-reference.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

3-
const inc = (obj) => {
4-
console.log(obj);
3+
const inc = (num) => {
4+
if (typeof num === 'object') {
5+
num.n++;
6+
}
57
};
68

79
module.exports = { inc };

Exercises/4-count-types.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
'use strict';
22

3-
const countTypesInArray = null;
3+
const countTypesInArray = (ArrayOfTypes) => {
4+
const countTypes = {};
5+
for (const item of ArrayOfTypes) {
6+
const type = typeof item;
7+
let count = countTypes[type];
8+
count = count ? count++ : count = 0;
9+
countTypes[type] = count;
10+
};
11+
12+
return countTypes;
13+
};
414

515
module.exports = { countTypesInArray };

0 commit comments

Comments
 (0)