Hi everybody, welcome back. Today, we're going to do what I call a Code with Me. Well, it's perfectly okay if you just sit here and watch the video and watch what I do. I really encourage people to take this as an opportunity to find out, can you do the things that you've been watching me do all along? Specifically, I'm wondering, can you declare an array? We've been talking about them, we've been using them, but I've been doing all the work. What if I asked you to declare array? Would you be stuck or can you jump right in? After you declare an array, can you access the different elements of an Array? So if you remember, each array is made up of as many different elements as you can think of. So, if you want to actually access this one right here, how do you do it? Next thing I want you to think about is can you add elements to array? If we want to add something after B, perhaps a C, do you know the proper JavaScript to use in order to make your code work? Let's jump right in. As I said, I have this code online for you. But I really encourage you to start from scratch and try coding on your own. And using my code as a reference just in case things go wrong. So let's go ahead and take a look at this code. I really want you to understand each and every line. Sometimes I do things the long way, but that's okay. Because I really think it's a great learning experience for you to understand what's going on with JavaScript. Let's start off with the fact that I declared an array with four different elements in here. I have Banana, Orange, Apple and Mango, I'm gonna use those inside my HTML code. In fact, where I use them, is I use it in the very first function called loadFruits. So when my page starts up, it's going to call that function and right away it says, you know what? I want you to grab everything that's in this array, all of it, and dump it right into this paragraph right here. This is why, again, if you look carefully at the HTML file, there's no fruits there. It's all being added by the JavaScript. Once you've got that kind of initial setup for your page, this is where we want to go in and we want to add elements to our array. So in order to add something, we basically don't wanna add it here. We want to add additional things to the end of our array. All right, let's get started. In this function, it's going to ask us what our favorite food is. Once they ask, we need to know where should we put it? So right now, I'm gonna kind of draw up on the screen to get an idea of what the index of each one of these elements is. It starts at 0, 1, 2 and 3. So this means we want to put the next fruit in position 4. So let's take a look. I click Add Your Favorite. I'll say Strawberry. And when I hit OK, right away the JavaScript has gone in and said, oh, I need to add this fruit to my whole array. The kind of cool thing is that, it doesn't say 4 here. I didn't say, I want it to go in position 4, because then it wouldn't work if I wanted to add more and more fruit. So this is where these little elements are coming together. You know that to add something to your array, you use the array name. So we have fruits, then you have to give it an index. And the easiest way to add something to an array is to just use the length of itself. So originally, I had four elements in my array. So perfect, I put it in position 4. Now the length of my array is one, two, three, four, five. So, because I'm using a variable here, instead of hard cutting a number. My program will work no matter how many different elements I add. So let's go ahead and add two more. And I can add Peach. And I can add another one. I'll just add Banana again cuz I have no imagination this morning. There we go. So this is a very simple example, but one that I want you to master. I want you to go in there, I want you to make your own array. Don't use fruit, use your favorite foods, use your favorite cars. Use your friends and take them on and off. And see if you can do these different things to manipulate an array. Once you feel comfortable doing this, you should feel confident going on in this class watching additional videos. And knowing that you do understand what's going on, even if you make a mistake now and then. So good luck.