Predict Callback Execution
Predict Output Easy
Question
What does this code print?
Code
function process(arr, callback) {
return arr.map(callback);
}
const result = process([1, 2, 3], x => x * 10);
console.log(result);
Hint
map applies the callback to each element.
Explanation
process takes an array and a callback, then calls arr.map(callback). The callback x => x * 10 multiplies each element by 10. So [1, 2, 3].map(x => x * 10) produces [10, 20, 30], which is printed.
Related Resources
Related Lessons
- JavaScript Functions
Learn about callbacks and higher-order functions.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.