how to callback function that takes a number as its argument code example
Example 1: callback function js
function greeting(name) {
alert('Hello ' + name);
}
function processUserInput(callback) {
var name = prompt('Please enter your name.');
callback(name);
}
processUserInput(greeting);
Example 2: how to pass callback function in javascript
function functionOne(x) { alert(x); }
function functionTwo(var1, callback) {
callback(var1);
}
functionTwo(2, functionOne);