Check out a free preview of the full JavaScript: From Fundamentals to Functional JS, v2 course:
The "forEach and _.each Exercises" Lesson is part of the full, JavaScript: From Fundamentals to Functional JS, v2 course featured in this preview video. Here's what you'd learn in this lesson:

In this exercise, loop through a list using each function. Then students implement _.each function.

Get Unlimited Access Now

Transcript from the "forEach and _.each Exercises" Lesson

[00:00:00]
>> So for the exercise, we're gonna first start by implementing the internals of an each function, right? So, just remember that each takes two arguments, a list, and a call back. It's gonna iterate through, each item in that list and call back with the values in that list, one at a time, right?

[00:00:24] So if we have a list of length 3, it's gonna to call the callback 3 times, each with one of those values. Also underscore each works for both arrays and objects. So that's something to consider. Once you finish, you can test it by running it by using it with the exercise from the previous module where we loop through our suspects lists and create a suspect objects.

[00:00:57] So, good luck, also don't forget that this is a little tricky here is that the underscore is gonna be an object.