Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
In this video, you'll make a variable
that stores the user's answer to name sprite's question.
A variable is a container the computer uses
to keep track of information it will use later.
To start, select the name sprite,
click on the Variable menu,
then click the Make a Variable button.
Name the variable something that makes sense
for the sprite you selected.
In this example, it's called Name.
This variable will store the answer the user types
when the program asks, What's your name?.
To set the variable to the answer that the user types,
drag out the set name to block,
and place it under the ask block.
Set the variable to Answer
to make the variable store the answer the user types.
Click on the Sensing menu, drag out the answer block,
and place it inside the blank space
of the set name to block.
This code stack reads, When this sprite is clicked,
ask, What's your name?,
and wait until the user types an answer.
Set the variable Name to the answer
that the user types.
Try it out!
Click the Name sprite and type in a name.
You'll see the name you typed in both the answer
and Name boxes on the screen.
In this example, that's Aaron.
To make just one box appear on your screen,
hide the answer box by clicking the check box
beside the answer block in the Sensing menu.
Now it's your turn.
Make a variable called Name.
Add a set variable to block under the ask and wait block.
Drag out the answer block from the Sensing menu,
and place it in the empty space
of the set variable to block.
Finally, remove the answer display from the screen
by clicking the checkbox beside the answer block.
In the next video, you'll make other variables
to complete the profile page.