+= operator doesn't work (Javascript)

Newest code, speed just remains 0.
When I add var to the second one, speed doesn’t remain 0.

var speed = 0;
var accel = 10;
var x = 0;
var y = 0;
var z = 0;

function Update () {
	speed = speed + Input.GetAxis("Vertical") * Time.deltaTime * accel;
	z = z + speed;
	print(speed);
	transform.Translate(x, 0, z);
}

EDIT: Never mind, it works now. What the problem was, is that “accel” is just too small to actually make a difference, Unity prints this as 0.

var speed = 0;
var accel = 10;
var x = 0;
var y = 0;
var z = 0;

function Update () {
    speed = speed + Input.GetAxis("Vertical") * Time.deltaTime * accel;
    z += speed;

    transform.Translate(x, 0, z);
}

Note that you use var to tell the compiler about your variables. Once you have declared them don’t use the var keyword when you use the variable.

var speed : float = 10;

function Update () {

var z = Input.GetAxis("Vertical") * Time.deltaTime * speed;
var x = Input.GetAxis("Horizontal") * Time.deltaTime * speed;
transform.Translate(x, 0, z);

}

Thanks Mac! What is the standard datatype it uses? Integer?
Coming from Actionscript, I assumed Javascript was kind of the same in managing variables as Flash. It’s not. I’ll remember that it’s not Actionscript and I’ll follow some Javascript tutorials.

var Speed : float = 0;

var accel : float= 10;

private var RelativeSpeed : float = 0;

private var x = 0;

private var z = 0;

function Update ()
{

Speed += Input.GetAxis("Vertical") *  Time.deltaTime * accel;

z = z + Speed;
Speed -= RelativeSpeed;
print(Speed);
transform.Translate(x, 0, z);

}