is there a way to move inverted ?

Hi everyone , I want when the player press the jump button he switch the line and move in the top and when he press again the jump button he comeback where he was .

bool onTopLine = false;

...

if (Input.GetKeyDown("Space"))
{
     onTopLine = !onTopLine;
     transform.position = new Vector3(transform.position.x, (onTopLine ? 1 : 0), transform.position.z);
}

...