Clamping negative and positive values.

I’m rather new to Unity. Though I’m familiar with JavaScript’s environment but not the best. Now what I’m trying to do is clamp the origin, for example, if X=0 and over time X increments by 1, if X>=10, X then starts to descend into negatives X -= 1 rinse-and-repeat for negative x hitting 10.

However, from past occurrences on other game engines, (using C++) I would just perform a Clamp(); to the value of X. Here’s my code at the moment.

transform.localPosition += Vector3(0 , 5 * Mathf.Sin( Time.deltaTime ) ,0);

Mathf.PingPong(Time.deltaTime, 20) - 10