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 Aand the variable name (declaration)
ITZand 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.”
Put your name into a new variable called, appropriately,
Print your name three times using the