Variables in Cuneiform are declared with the "var" keyword, followed by the variable name. There are two types of variables in Cuneiform.
Similar to languages like Javascript, Cuneiform variables are containers for storing data values. In this example, x, y, and z are variables.
var x = 5;
var y = 3;
var z = x + y;
From the example above, you can expect
Creating a variable in Cuneiform is called "declaring" a variable. Variables are declared with the var keyword.
var age;
After the declaration, the variable has a value of null. To assign a value to the variable, use the equal sign.
age = 22;
You may also assign a value to the variable when it is declared.
var age = 22;
Cuneiform variables can hold numbers such as 100, and text values like "John Doe". In programming, text values are known as "strings".
Strings are written inside double quotes. Numbers are written without quotes. If a number is put in quotes, it will be treated as a text string. For example,
var pi = 3.14;
var name = "John Doe";
var age = 22;
In addition to numbers and strings, Cuneiform can handle many types of data such as Objects, Arrays, and System operations.
Similar to algebra, we can perform arithmetic with Cuneiform variables, using operators such as = and +. Some examples are as follows:
var x = 5 + 2 + 3;
var y = -10;
var z = (x + y) * 100 - (-30);
Strings can also be added, but they will be concatenated.
var firstName = "John";
var lastName = "Doe";
var fullName = firstName + " " + lastName;
Objects and Arrays are types of Cuneiform variables that can hold multiple amounts of data. In the next section, we will discuss them in more detail.