Closures and Callbacks
Inline Callbacks
Write a callback where it is used.
Inline Callbacks
inline_callback.js
const bonus = 1;
const scores = [10, 20, 30];
const adjusted = scores.map((score) => score + bonus);
console.log("bonus=" + bonus);
console.log("adjusted=" + adjusted.join(","));
inline-callback
An inline callback keeps the transformation next to the array method. It can still read nearby variables such as `bonus`.