Check out example codes for "unity3d find y position on navmesh". It will help you in understanding the concepts better.

Code Example 1

private bool SetDestination(Vector3 targetDestination)
{
  NavMeshHit hit;
  if (NavMesh.SamplePosition(targetDestination, out hit, 1f, NavMesh.AllAreas))
  {
    agent.SetDestination(hit.position);
    return true;
  }
  return false;
}

Learn ReactJs, React Native from akashmittal.com