In JavaScript, you can define a function and pass it as an argument to another function.
Such a function, is called a callback function.
Let us have a look at an example:
In the above code we see 2 functions validateSolution
and statusMessage
.
statusMessage
is passed as an argument to validateSolution
, this makes statusMessage
a callback function.
This example showcases the use of a callback function statusMessage
to handle and display the success or error status based on the result of the validation process done in the validateSolution
function.