Learn

Suppose we are building a game, and we want to keep track of the item names and their in-game prices. We need some variables!

In many cases, you will only assign a variable once, i.e. store a value into it, and then use it without ever changing it. These are the cases where you should use a constant variable.

Constant variables are extremely easy to use in Emojicode:

3.14 ➡️ pi
  • 3.14 is the value of the variable.
  • ➡️ is the assignment operator.
  • pi is the name of the variable.

Here, the value on the left-hand side of the ➡️ is stored into the pi constant variable.

Note: You cannot change a constant variable. If you try to reassign a constant variable, this will result in a compiler error.

Instructions

1.

Declare a constant named year with a value of the current year.

Take this course for free

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

Already have an account?