Variables



Variables can be used to compute info, to write certain info on a screen. (Say you wanted a sentence to be written down a lot, you could make it a variable and you could just have that variable be written.)

You can define variables in a few ways.
var a //creates a var called a. This has no value as of now
var a = 5 //sets it to 5
var a = 10// Changes the value to 10
var b = "Hi there!! How are you?"//assigns a string of words to var b
var c = 2.567 //assigns a decimal to var c


To have a variable written on the page, do this:
document.writeln(varname)
The next section is operators
Back Homepage JavaScript Basics Next