We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b107a4d commit 6152b71Copy full SHA for 6152b71
34_example-callback.js
@@ -0,0 +1,35 @@
1
+// example again callback-function
2
+
3
4
5
6
+let add = function(a , b){
7
+ return a + b;
8
+}
9
10
+let multiply = function(a , b){
11
+ return a * b;
12
13
14
+let calculation = function(num1, num2, callback){
15
+ return `The result from ${num1} and ${num2} is ${callback(num1, num2)}`;
16
17
18
+console.log(calculation(10,10,add)); //20
19
+console.log(calculation(20,20,multiply)); //400
20
21
+/*original
22
23
+let calc = function(num1, num2, calcType){
24
+ // conditional
25
+ if(calcType === 'add'){
26
+ return num1 + num2;
27
+ }else if(calcType === 'multiply'){
28
+ return num1 * num2;
29
+ }
30
31
32
+//access function
33
+console.log(calc(20,20,'add')); //40
34
35
+*/
0 commit comments