Skip to content

Commit b09cc6a

Browse files
committed
Добавила 3 решения задач DataTypes
1 parent af31b0a commit b09cc6a

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
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 = function raising() {
4+
const variable = 'Hello';
5+
console.log(variable);
6+
};
47

58
module.exports = { fn };

Exercises/2-by-value.js

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

3-
const inc = null;
3+
const inc = (x) => ++x;
4+
5+
// function inc(n) {
6+
// return n+1;
7+
// }
48

59
module.exports = { inc };

Exercises/3-by-reference.js

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

3-
const inc = (obj) => {
4-
console.log(obj);
3+
const inc = function(obj) {
4+
obj.n += 1;
55
};
66

7+
// function inc(num) {
8+
// if (num && typeof num.n === 'number') {
9+
// num.n += 1;
10+
// } else {
11+
// throw new Error("Invalid input: Object must have a numeric 'n' field");
12+
// }
13+
// }
14+
715
module.exports = { inc };

0 commit comments

Comments
 (0)