Move object with max speed and stop

Hi, i try doing javascript for move object to maximum speed and stop, but i have problem with set a maximum speed. Object still accelerate to infinite speed. Here is mi script:

var maxspeed = 0;
var acceleration = 0;
var stop = 0;
var time = 0.1;
var speed = 0;

function Update () 
{
	time += Time.deltaTime;
	transform.Translate(Vector3.right * Time.deltaTime * speed / 10);

	if(time < stop)
	{
		if(acceleration < maxspeed)
			{
				speed += acceleration;
			}
	}		
	else
	{
		speed -= acceleration;
		if(speed < 0)
		{
			time = 0;
		}
	}
}

You compare acceleration with maxSpeed, you need to compare speed to maxSpeed:

if(time < stop)
{
   if(speed < maxspeed)
     {
      speed += acceleration;
     }
}