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.



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

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?