August 14, 2009

Javascript Tutorial 3: More on Variables

var name="test";
alert (name);
Recalls variable "name" into an alert box.
Now use the same variable double (use the first and the second)

var name="test";
alert (name);

You do not need to recall the variable with var tag. With this code, both of the popups will come up one after the other.

var num1=10;
var num2=15;
var answer=(num1+num2);
alert (answer);

This gives the answer of 10+15, the two variables in an alert box of a variable.

Technorati Tags: , , , ,

No comments:

Post a Comment