Skip to content

Commit 7e1728b

Browse files
committed
Add callback-last-error-first contract
1 parent 6de39f9 commit 7e1728b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

JavaScript/1-callback.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ const sum = (a, b, callback) => callback(a + b);
1212
sum(2, 3, (res) => {
1313
console.log(`sum(2, 3) = ${res}`);
1414
});
15+
16+
// Callback-last-error-first
17+
18+
const total = (a, b, callback) => callback(null, a + b);
19+
20+
total(2, 3, (error, res) => {
21+
console.log(`sum(2, 3) = ${res}`);
22+
});

0 commit comments

Comments
 (0)