Skip to Content
Learn
Hello, LOLCODE!
Variables

It can be useful to store a value and use it later. This is called a variable in many programming languages and can be very useful when we want to use something multiple times.

LOLCODE’s variables work similarly to variables in other languages. They have similar naming restrictions and need to be declared before they’re used:

I HAS A [variable] ITZ [value]
  • I HAS A and the variable name (declaration)
  • ITZ and the value to store (initialization)

For example, to declare a message variable and give it a string value:

I HAS A message ITZ "Ceiling cat is watching you!"

And suppose we want to print the message multiple times, instead of copy & pasting it repeatedly, we could simply do:

VISIBLE message VISIBLE message

I HAS A is the lolspeak version of “I have a.”
ITZ is the lolspeak version of “it’s.”

Instructions

1.

Put your name into a new variable called, appropriately, name.

2.

Print your name three times using the name variable.

Folder Icon

Take this course for free

Already have an account?