Variables (Var)
A LOCAL VARIABLE IS A SYMBOL OR NAME THAT REPRESENTS A VALUE.
Interactive Lesson: Click Here
Let's begin!
Example

First, we declare a variable 'x' and assign a value of 0 to it.

Second, we output the value of 'x' so that the user will be able to see it. In this case, the output will be 0.

We can update the value of 'x' by using the := operator and assign a new value to it. In this case, we assign the value of 2 to 'x' and show the output.

We can use variables to add to another variable or itself! In this case, we add 'x' to itself and update the new value to 'x'.The output of 'x' will be 2+2 = 4

We can create a new variable and assign the value of another variable to the new variable.In this case, we create a new variable 'z' and assign the value of 'x' to it!

Variables can also be used for Strings or Actions where the action's data can be saved!In the above example, we create a variable 'y' and assigned a string of "Hello World" to it.

However, do take note that variables of different type cannot be assigned to each other! In the above example, 'y' has a type of String and 'x' has a type of Number.
Conclusion
- A variable is a symbol or name that represents a value.
- Values can be of different data type such as Number, String, Boolean (True / False) and more!
- Variables makes programming more efficient because data can be accessed and updated easily!
- Variables of different type cannot be assigned to each other!