How to use call backs in JavaScript

Let suppose If there are two variables like num 1 and num 2 and there is a method having that num 1 and num 2. now we want to call that method at the end so we can use this call back method .


<script>
function myDisplayer(some) {
  document.getElementById("demo").innerHTML = some;
}



function myCalculator(num1, num2) {
  let sum = num1 + num2;
  myDisplayer(sum);
}



myCalculator(5, 5);
</script>

Leave a comment

Your email address will not be published. Required fields are marked *