Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Array Iteration Methods Array Iteration `for` vs forEach()


Why do we need to pass a parameter.Example

const numbers = [1, 2 , 3 ,4 , 5] 
numbers.forEach( number =>{


whats the point of the number word

1 Answer

Mark Sebeck
Mark Sebeck
Treehouse Moderator 36,475 Points

The foreach will call the callback function once for each element of the array numbers. As it iterates through the array number is the value of the current element in the array. So the first time it calls the call back function it will pass the first element (1) and the second time it will pass 2.

Here's a helpful link

Hope this help!