How to send object in Opposite direction

I have a cube. I want it to move left and right on the screen.

How can i make the cube on the screen move the opposite direction after a set time?

It moves along the x axis.

void Update () {

StartCoroutine(Example());
}

IEnumerator Example() {
float f = speed * Time.deltaTime;
transform.Translate(f,0,0);
yield return new WaitForSeconds(5);
// after 5 secs send the object the opposite direction
}

IEnumerator Example() {
float f = 0;
if(forward)
f = speed * Time.deltaTime;
else
f = -speed * Time.deltaTime;

transform.Translate(f,0,0);
yield return new WaitForSeconds(5);
if(!forward)
forward = true;
else
forward = false;
// after 5 secs send the object the opposite direction
}

Hope this helps! Good Luck