Repository navigation
Description
Describe the Issue
The callback definition under ‘Callback Functions and the forEach Method’ is incorrect in both the Higher Order Functions review and the JavaScript chapter review. It says the callback runs after the main function has finished. Synchronous callbacks, including the forEach example immediately below the definition, run before the receiving function returns.
This is a follow-up to #64439. #64758 corrected the chapter review, but #66056 reintroduced the old definition. The module review also still contains it. Both copies are present on main at f599986.
Affected Page
Your code
Reproduction run in Node.js:
const order = ['before forEach'];
[1, 2].forEach(value => order.push(`callback ${value}`));
order.push('after forEach');
console.log(order);Actual output:
[ 'before forEach', 'callback 1', 'callback 2', 'after forEach' ]
Expected behavior
Both reviews should use the definition already in the corresponding lecture: a callback is passed to another function so that the outer function can invoke it at a specific point. The definition should not require the outer function to finish first.
Screenshots
No response
System
- Device: Linux development environment
- OS: Linux
- Browser: Not applicable; reproduced from the curriculum source with Node.js
- Version: Node.js v24.22.1
Additional context
Affected source files:
- https://github.com/freeCodeCamp/freeCodeCamp/blob/f5999861310d414d93119930152b38755cb3e09f/curriculum/challenges/english/blocks/review-javascript-higher-order-functions/6723ca6c6db3deb21cb1bf19.md
- https://github.com/freeCodeCamp/freeCodeCamp/blob/f5999861310d414d93119930152b38755cb3e09f/curriculum/challenges/english/blocks/review-javascript/6723d3cfdd0717d3f1bf27e3.md
MDN also identifies forEach and map callbacks as synchronous: https://developer.mozilla.org/en-US/docs/Glossary/Callback_function
Searched open issues and PRs for callback, higher order, and the affected review identifiers; found no open report or fix for these definitions.
Activity