Hello friends, In this short article, we will see, how can we call one function inside second in JavaScript.
Let's consider you have a function named makeAddition() as follows:function makeAddition(a,b){ var c = a+b; alert("Addition: "+ c); }Now if you have another function named makeSubtraction() as follows:
function makeSubtraction(a,b){ var d = a-b; alert ("Subtraction: "+ d); }You can call makeAddition function inside makeSubtraction function as follows:
function makeSubtraction(a,b){ var d = a-b; alert ("Subtraction: "+ d); makeAddition (4,5); }Now when you call makeSubtraction (10,5), it will first alert answer as 5 and then it will call makeAddition function and will alert answer as 9.
0 Comments