Skip to content

Commit 7d32245

Browse files
fix(curriculum): adjust callback explanation (freeCodeCamp#64758)
1 parent 3ebcc0e commit 7d32245

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

curriculum/challenges/english/blocks/lecture-working-with-higher-order-functions-and-callbacks/67329ffd75010f5ddeb4ea13.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This concept is fundamental to understanding many aspects of JavaScript, includi
1313

1414
Let's start by understanding what a callback function is in a simple context.
1515

16-
Imagine you have a function that performs a task, and you want to do something after that task is complete. Instead of writing all the code in one big function, you can pass a second function (the callback) to be executed when the first function is done. This allows for more flexible and modular code.
16+
Imagine you have a function, and within the function you want to do something multiple times. Instead of writing all the code in one big function, you can pass a second function (the callback) to be executed whenever you need that specific something to be done. This allows for more flexible and modular code.
1717

1818
Now, let's introduce the `forEach` method. `forEach` is a built-in method for arrays in JavaScript. It allows you to iterate over each element in an array and perform an operation on each element. The operation you want to perform is defined in a callback function that you provide to `forEach`.
1919

curriculum/challenges/english/blocks/review-javascript/6723d3cfdd0717d3f1bf27e3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ console.log(Math.subtract(5, 3)); // 2
13521352
13531353
## Callback Functions and the `forEach` Method
13541354
1355-
- **Definition**: In JavaScript, a callback function is a function that is passed as an argument to another function and is executed after the main function has finished its execution.
1355+
- **Definition**: In JavaScript, a callback function is a function that is passed as an argument to another function to be invoked at some point from the first function.
13561356
- **`forEach()` Method**: This method is used to iterate over each element in an array and perform an operation on each element. The callback function in `forEach` can take up to three arguments: the current element, the index of the current element, and the array that `forEach` was called upon.
13571357
13581358
```js

0 commit comments

Comments
 (0)