Created
October 9, 2019 14:38
-
-
Save RashidJorvee/5c9e846b9c72e9badc0118b1da4bf008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function third(val, callback){ | |
callback(val*2, false); | |
} | |
function second(val, callback){ | |
callback(val*2, false); | |
} | |
function first(val, callback){ | |
callback(val*2, false); | |
} | |
first (2, function(result1, err) { //calling first function with parameters, val 2 and a callback function. | |
if(!err) { // if execution of first function is successfull. | |
second(result1, function(result2, err) { // calling second function, in parameter we are passing the result of first function and a callback | |
if(!err){ // if execution of second function is successfull. | |
third(result2, function(result3, err) { // calling third function, in parameter we are passing the result of second function and a callback | |
if(!err){ // if execution of third function is successfull. | |
console.log(result3) //printing the result from third function on console. | |
} | |
}); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment