Day 4: Functions Calling Functions & Callbacks
Daily Objective
Section titled “Daily Objective”Compose modular functions and understand higher-order functions that accept callbacks.
1. Callback Functions
Section titled “1. Callback Functions”A callback is a function passed into another function as an argument:
function processTransaction(amount, callback) { console.log(`Processing payment of $${amount}...`); callback(amount);}
const sendNotification = amt => { console.log(`Receipt emailed for $${amt}`);};
processTransaction(75, sendNotification);Daily Hands-on Practice (70%)
Section titled “Daily Hands-on Practice (70%)”- Write a
calculate(a, b, operationCallback)function that accepts an operation function (add, subtract, etc.) and returns the result.