So now you might ask, how do we print the value of a constant to the terminal? Oftentimes, we find ourselves needing to print constant values as part of a message in the terminal. In these cases, we can use string interpolation.

String interpolation can be used to construct a string from a mix of constants, variables, and others by including their values inside a string literal.

In Emojicode, to insert a value into a string using string interpolation, we can write the variable inside two ๐Ÿงฒs and it will print its value.

Suppose we have a constant named height with a value of 3000, and we want to use string interpolation to print out a fun fact:

3000 โžก๏ธ height ๐Ÿ˜€๐Ÿ”คAlex Honnold climbed El Capitan, which is ๐Ÿงฒheight๐Ÿงฒ feet, without a rope!๐Ÿ”คโ—๏ธ

It will output:

Alex Honnold climbed El Capitan, which is 3000 feet, without a rope!




Output the constant year using ๐Ÿ˜€ โ—๏ธ and string interpolation so that the terminal looks like:

The current year is [year]

Where [year] is the value of 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?