What is a Callback Function?
A callback function is a function passed as an argument to another function and is executed after the completion of that function.

See the step-by-step examples in the code above and the console output.

Step-by-step Callback Example:
// 1. Simple function (no callback)
function greet(name) {
    return 'Hello, ' + name + '!';
}
console.log(greet('Alice')); // Output: Hello, Alice!

// 2. Function that takes a callback
function processUserInput(name, callback) {
    return callback(name);
}

// 3. Pass a named function as callback
function sayGoodbye(name) {
    return 'Goodbye, ' + name + '!';
}
console.log(processUserInput('Bob', sayGoodbye)); // Output: Goodbye, Bob!

// 4. Pass an anonymous function as callback
console.log(processUserInput('Charlie', function(name) {
    return 'Welcome, ' + name + '!';
})); // Output: Welcome, Charlie!

// 5. Pass an arrow function as callback
console.log(processUserInput('Diana', name => 'Hi, ' + name + '!')); // Output: Hi, Diana!