Learn

Now that you know a bit about variables, let’s code some ourselves!

We create or declare a variable by giving it a name and setting it equal to a value.

terrain = 'lake'

In the code editor, we’ve written out an example of a variable declaration. We’ve included one variable in the workspace, named one, and it’s currently set to 'grass'.

Instructions

Below variable ‘one’, declare a variable called two. Set variable ‘two’ to equal 'rocks'. Remember to pay attention to details, like punctuation.

Next, create a variable three and set it equal to 'forest'.

Run the code! How does the board game change?

Now, try replacing the values with other ones that you’ve seen in this lesson! Here’s the full list:

Group 1:

  • grass
  • rocks
  • forest

Group 2:

  • lake
  • beach
  • town

Group 3:

  • glacier
  • desert
  • moon

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?