Skip to content

Commit 10ef09d

Browse files
author
DouglasHdezT
committed
Add: Callback example
1 parent a1a5f82 commit 10ef09d

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

2-Callbacks/Example1.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Callbacks
3+
*/
4+
5+
function runCallback(a, b, callback) {
6+
console.log(`A = ${a}`);
7+
console.log(`B = ${b}`);
8+
9+
if (a > b) {
10+
console.log("A > B");
11+
} else {
12+
console.log("A <= B");
13+
}
14+
15+
callback(a + b);
16+
}
17+
18+
console.log("--- Show time ---");
19+
runCallback(5, 4, function (c) {
20+
console.log(`A + B = ${c}`);
21+
console.log(`sqrt(A + B) = ${Math.sqrt(c)}`);
22+
});

0 commit comments

Comments
 (0)