NOTE: Learn more about variables and other concepts on your teacher dashboard. Each unit has an overview that explains the concept in detail. https://dashboard.kodable.com/#/curriculum/3

Variables store information, or values, in a program. There are different types of variables that are used in different situations: strings, integers, and arrays.

We learned that strings are groups of characters, like words or phrases- and Integers are whole numbers, like 5, 50, or 500. Arrays keep code organized and help make storing values more efficient.

Definition: Arrays are ordered lists of related variables and include both strings and integers.

In real life: In real life, you can think of your closet as an array- you use your closet to organize your clothes and keep them in a specific order. The order you hang your clothes in organizes them in a defined way- your shirts are going to stay where you hang them.

Let’s say on Sunday night you’re planning your outfits for Monday, Tuesday, and Wednesday and hanging your shirts in the order you’ll be wearing them. When you hang your green dress shirt on the far left spot in your closet for Monday, your blue t-shirt in the middle of the closet for Tuesday, and your favorite red shirt on the right in your closet for Wednesday, they will be where you hung them and organized in this way when you need them throughout the week.

In Programming: In programming, we can store related data in an array, grouping the related values into an ordered list.

In the final part of each lesson, students will independently practice using arrays to clear the asteroid field. Arrays in the world of Asteroidia work like they do in programming. Arrays are used to make code cleaner and more efficient, so students can use an array to get 3 moves with just one command. This allows students to solve some levels in just one move.

In this lesson, the colors represent string variables. There are 6 different values used here: red, pink, yellow, green, blue, and purple. I need to correctly order my list of variables in the command bin to be able to clear the asteroid field when I match the values: I see that I need to first clear red, pink, then yellow, and so on. I order the values in my array this way so that I can successfully clear the asteroid field by matching the values from my command bin with the values in the field.

In the code that our programmers wrote at Kodable, class lists are as an array. You have your students use a class code to log into Kodable- when a class code is used, it brings up data stored as an array and loads a list of students’ name. Your students see their class list on their screen and are able to select their name to log into their profiles.

Why We Use Arrays: Arrays make storing and finding values easier and efficient. Programmers can use one command to search all of the values stored in one array, without needing to know what each variable may be.

Did this answer your question?