before using them. You do this using the var
first time you
must use the var
. At all other times, using the
before their use is a recommended practice.
var variable1 = "I am using my first
// The value stored in variable1 is of string data type.
// The sentence in quotes, the value of which is assigned to variable1, is a string
var variable2 = 3;
// The value stored in variable2 has numeric data type.
var variable3 = true;
// The value stored in variable3 has Boolean type.
var variable4 = 2.718281828
// The value
stored in variable4 has numeric type.
case-sensitive language, so naming a variable Variaiable1
from naming it VARIABLE1
- The first character must be a letter (either uppercase or lowercase)
or an underscore (_), or a dollar sign ($).
- Subsequent characters can be letters, numbers, underscores, or
- Jhon&Smith // Ampersand (&) is not a valid character for use in
In instances in which you
particular value, you may assign it a special value, as null
var variable9 = null;
var variable8 = 3 * variable9; // At this
point, Variable8 becomes 0 as result.
it, it exists but is undefined.
var variable2 = 1 * variable1;
// Places the value NaN in variable2 as variable1is undefined.
You can declare a variable implicitly without using var statement in
a value to it. You cannot, however, use a variable that has never been
declared at all. To do so generates an error at runtime.
variable4 = "";
// The variable variable4
is declared implicitly.
var variable5 = var1 + var2; // Generates an error because var1 and var2 don't
To begin with, the information is not saved after each surfing
. In order for this to work, you must ensure
the user moves in a linear fashion. Returning and backing up can harm
the information being carried.
Next, the way I have this set up, you can only transfer two variables
from page to page. You'll see why in a moment.
Also, the method I have written here isn't very friendly to spaces.
If the user puts a space in either of their two text boxes, that space
will be replaced by a plus sign. If you're going to accept spaces, you'll
either have to live with that or write some extra code to eliminate it.
the most browsers can understand what is to happen. I saw a suggestion on
doing this by setting the answers to an array. It's clever coding but it's
method allows for endless
browsers. Mine allows for the most number of browsers to be able to play