Want to know more about us and our multimedia, animation & web design courses, feel free to Contact Us. We would love to hear from you.
In below example, a, b, and c, are variables:
var a = 4;
var b = 7;
var c = a + b;
var pi = 60.2;
var person = "Pawan Negi";
var answer = 'Yes I am!';
After the declaration, the variable doesn't have any value. (Technically it has the value of undefined)
To assign a value to the variable, use the equal sign:
myName = "Rahul";
You can also assign a value to the variable when you declare it:
var myName = "Rahul";
In the example below, we create a variable called myName and assign the value "Rahul" to it.
Then we "output" the value inside an HTML paragraph with id="demo":
Create a variable called age, assign the value 21 to it, and display it.
Display the sum of 2 + 8, using two variables a and b.
Create a third variable called c, assign a + b to it, and display it.
E-mail : email@example.com
ADDRESS: H-17 / 263, First Floor,Sector 7,
Near Rohini West Metro Station,
Opposite Metro Pillar No. 425
Rohini, Delhi - 110085
|Monday To Friday||8:00 Am To 7:00Pm|
|Saturday||10:00 Am To 6:00Pm|