moving object no PingPong

is possible to move an object from left to right (or vice versa) without the use of Mathf.PingPong? I found this script in C # that I wanted to recreate in js but does not understand how to move.

using UnityEngine;
using System.Collections;

public class MovingObject{
    public DirectionEnum direction; //-1 or 1;
    public Transform transform;

    public MovingObject(DirectionEnum dir, Transform trans)
    {
        direction = dir;
        transform = trans;
    }
    
}

[System.Serializable]
public enum DirectionEnum{left = 1, right= 1}

public class ObjectSpawner : MonoBehaviour {

    public Transform objectPrefab;
    public DirectionEnum spawnDirection = DirectionEnum.right;
    public static ObjectSpawner SP;

    private float farLeft;
    private float farRight;    
    private float lastSpawnTime;
    private float spawnInterval;   


	void Awake () {
        SP = this;
        
        spawnInterval = Random.Range(3.5f, 5.5f);
        lastSpawnTime = Time.time + Random.Range(0.0f, 1.5f);
	}

    
	void Update () {
        //Spawn new object..
        if ((lastSpawnTime + spawnInterval) < Time.time)
        {
            SpawnObject();
        }      
	}

    void SpawnObject()
    {        
        lastSpawnTime = Time.time;
        spawnInterval *= 0.99f;//Speed up spawning

        DirectionEnum direction = spawnDirection; //-1 or 1

        Transform newObj = (Transform)Instantiate(objectPrefab, transform.position, transform.rotation);
        MovingObject movObj = new MovingObject(direction, newObj);        
        GameManager.SP.AddTarget( movObj );
    }

 
}

Here is a script which moves left to right like ping-pong that you can use as start:

public class Test : MonoBehaviour {
	
	public float speed = 5;
	public float farLeft = 5;
	public float farRight = 5;
	float direction = 1;
	Transform tfm;
	Vector3 farLeftPos, farRightPos;
	
	void Start() {
		tfm = transform;
		farLeftPos = tfm.position - tfm.right * farLeft;
		farRightPos = tfm.position + tfm.right * farRight;
	}
	
	void Update() {
		Vector3 desiredPosition = tfm.position + tfm.right * 0.2f * direction;
		tfm.position = Vector3.Lerp(tfm.position, desiredPosition, Time.deltaTime * speed);
		Vector3 checkPos = (direction > 0 ? farRightPos : farLeftPos);
		if (Vector3.Distance(tfm.position, checkPos) <= 0.3f) {
			direction *= -1;
		}
	}
}