Learn To Code Part III: Arrays And Logic Statements

Learn To Code Part III: Arrays And Logic Statements

You’ve mastered the basics of variables and made it half way through our course, but are you up to the challenge of arrays and logic statements? Of course you are. Let’s get started!

These lessons work best with the video, which you can see above, but we’re also providing text for reference below. Even if you do prefer to read, the videos will be more explicit and demonstrate how to do everything we’re discussing. If the text seems a bit too complicated, be sure to watch the video.

This is where things get a bit more complicated. There’s no need to be intimidated by what’s to come, but just know you might hit a point of frustration because we’re going to cover some of the more complex — but incredibly useful — stuff today. This is going to be the hardest (and longest) part of the beginner lesson, but you can do it. You just may need to rewind and practice a little bit more than with the previous two lessons.

First, we’re going to learn about arrays. After that, we’re going to take a look at if statements and for loops, and also how to use those tools with your array.


An array is a type of variable, but it’s more like a box with a bunch of sections. Unlike the simple variables we’ve discussed before, arrays can contain more than one piece of data. Let’s take a look at how an array can be defined and then we’ll talk about what it all means.

var myArray = new Array(“Lisa”, “George”, “Adam”, “Paloma”, “Jeffrey”);

I’ve just created an array called myArray that contains five names. Each is separated by a comma and each name is in quotes because they’re strings (if you forgot what a string is, refer back to lesson one). As you might have guessed, arrays are really useful for storing a bunch of similar data inside of one variable for easy access. It’s kind of like a mini database. When you want to access an item in an array you do so by number.