Skip to content

Commit 1872b46

Browse files
committed
Code style
1 parent 3b1c05d commit 1872b46

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

JavaScript/1-sync-try.js

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

3-
function sum(a, b) {
3+
const sum = (a, b) => {
44
if (typeof(a) === 'number' && typeof(b) === 'number') {
55
return a + b;
66
} else {
77
throw new Error('a and b should be numbers');
88
}
9-
}
9+
};
1010

1111
try {
1212
console.log(sum(2, 3));

JavaScript/2-sync-tuple.js

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

3-
function sum(a, b) {
3+
const sum = (a, b) => {
44
if (typeof(a) === 'number' && typeof(b) === 'number') {
55
return [null, a + b];
66
} else {
77
return [new Error('a and b should be numbers')];
88
}
9-
}
9+
};
1010

1111
console.log(sum(2, 3));
1212
console.log(sum(7, 'A'));

JavaScript/3-async.js

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

3-
function sum(a, b, callback) {
3+
const sum = (a, b, callback) => {
44
if (typeof(a) === 'number' && typeof(b) === 'number') {
55
callback(null, a + b);
66
} else {
77
callback(new Error('a and b should be numbers'));
88
}
9-
}
9+
};
1010

1111
sum(2, 3, (err, result) => {
1212
if (err) {

JavaScript/4-uncaught.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ process.on('uncaughtException', (e) => {
44
console.log('on uncaughtException: ' + e.message);
55
});
66

7-
function sum(a, b) {
7+
const sum = (a, b) => {
88
if (typeof(a) === 'number' && typeof(b) === 'number') {
99
return a + b;
1010
} else {
1111
throw new Error('a and b should be numbers');
1212
}
13-
}
13+
};
1414

1515
console.log(sum(2, 3));
1616
console.log(sum(7, 'A'));

0 commit comments

Comments
 (0)