There are no hard and fast rules that you must obey in choosing a variable name, but it is best that you choose a name that is meaningful as it makes debugging your program easier.For example, you can use Tel_No for the telephone number, which is better than just using a variable x.
4.2 Assigning Values to Variables
After you have created a variable, you can assign a value to it. The value can be in the form of a number( numeric value), text (String) or boolean (true or false).
var variable_name= value
Example 4.2(a): Assigning a numeric value
var mark = 20 var sell_price=100 var age = 40 var height = 180 var temp = 30
Example 4.2(b) Assigning a String
var First_Name="George" var car_model = " Laser 100" var Company_Name = ' Ultra Mobile LLC '
Note: The string must be enclosed in quotation marks(either double or single)
Example 4.2(c) Assigning a Boolean value
var paid = true var alive = false var positive = true
Let’s apply what have learned about values assignment in the following example:
Click Example4.3(a) to view the output.