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

In this exercise, you will create a number of functions to access data in the application.

Get Unlimited Access Now

Transcript from the "Functions Exercise" Lesson

>> [MUSIC]

>> Bianca Gandolfo: So now it's exercise time. So if we just go back where we were, sort of like our table of contents. You can just go to the functions exercise and get started and it's the same. It's all in the scripts.js file or in your JS Bin. And you're gonna go through and put some functionality in there.

[00:00:29] So and we'll have about, 30, let's see what time is it, 2? Yeah, we'll have about 40 minutes for these is a little bit longer. So, let's go with 40 minutes.
>> Speaker 2: There's a question in the chat room here.
>> Bianca Gandolfo: So, Pete asked, how does AnimalMaker know when it is passed an array?

[00:01:01] It is pass and array and has to iterate through it versus just grabbing the first value. So we're actually explicitly, where are my slides? We're actually explicitly looping through it. So AnimalMaker, the function itself knows nothing of the array. What we're actually doing is we're just looping. And here actually, this slide up here makes it a little more clear.

[00:01:30] So this four loop is actually what's doing the looping part, and inside of the four loop, we're actually passing the animal name, we can see it here. This is where we're calling AnimalMaker, and we're not calling AnimalMaker with the entire array. We're actually calling it with one value in the array.

[00:01:47] So, animalNames[i], so the first one, the zero in index would be sheep. So it's saying, AnimalMakers, and then you could replace that right here with sheep, for example.
>> Speaker 2: [INAUDIBLE].
>> Bianca Gandolfo: So that's how it knows. Does that answer your questions? Cool.