Check out example codes for "unity pingpong". It will help you in understanding the concepts better.

Code Example 1

void Update()
    {
        // Set the x position to loop between 0 and 3
        transform.position = new Vector3(Mathf.PingPong(Time.time, 3), transform.position.y, transform.position.z);
    }

Learn ReactJs, React Native from akashmittal.com