Episode 1 13/24
Are you sure you want to leave this episode?
Yep!
Variables and comparisons
A variable is a piece of code where you can store and change data. For instance we can create a variable where we store numbers.
Creating a variable on MakeCode.
For a program to know there is an active variable you first must create it or declare it. That's what we are going to do now. Go to VARIABLES, then MAKE A VARIABLE, give it a name (we called it 'element'), and SAVE!
Adding logic to the variable.
Now let's go to the LOGIC section, grab a COMPARISON BLOCK and drop it to your program. Drag and drop your variable inside of the first oval so that the program now says 'when variable is 1', like this:
Your conditional code should now look like this: