What are String Variables?
Jon Mattingly avatar
Written by Jon Mattingly
Updated over a week ago

Variables store information in a program. You can think of variables like a box or a container with a name on them, related to the things inside. These items inside are called values, which can be stored as text or numbers. When you use a variable in a program you’re able to control the output of the program, or what a user sees. Learners are introduced to string variables in Game Designer.

There are many different types of values that can be stored in a variable. In Kodable, we focus on three: Strings, Integers, and Arrays.

A string is a type of value that can be stored in a variable. A string is made up of characters, and can include letters, words, phrases, or symbols.

Definition: Strings hold groups of characters, like a word or a phrase.

In Real Life: An easy way to think about strings in real life is to think about the way your brain stores people’s names. Think of a person as a variable here: a name is just like a string: it as a value that your brain uses to identify a person. Variables have values that can change, or vary, just like a person’s last name can change when they get married, or a friend starts calling then by a new nickname.

In Programming: In programming, strings allow programmers to easily store, find, and change information in a program.

In Kodable, learners practice creating their own game by storing strings, which are represented by colors. When learners put a color in the command bin, they are assigning a value to the variable. Learners will match the variable with an asteroid type to clear the asteroid field.

When like asteroids touch in the asteroid field, they will clear on their own. Learners need to think critically and use as few variables as possible to clear the asteroid field.

In this level, we can see how learners will assign values to variables by using the colored fuzzballs on the left. Like-variables will clear on their own.

Let’s think about how strings work in programming- we can think about video games and how a game developer controls what the player sees. A character’s name, hair color and eye color are stored as strings in a video game, making it easy for programmers to know or change what variables represent specific information in the code. A programmer working on the game could type in the variable for the character’s eye color and edit the value from “blue” to “brown”, instantly changing the character’s eye color in the game.

Why We Use Strings: String variables allow programmers to easily find information in their code and reuse values in their programs. Variables can change- think vary- and strings make it easy for programmers to read and change values assigned to different variables throughout their programs.

Did this answer your question?