The randomized Kaczmarz (RK) method is a randomized iterative algorithm for solving (overdetermined) linear systems of equations. In this paper, we extend the RK method to function approximation in a bounded domain. We demonstrate that by conducting the approximation randomly one sample at a time the method converges. Convergence analysis is conducted in terms of expectation, where we establish sharp upper and lower bounds for both the convergence rate of the algorithm and the error of the resulting approximation. The analysis also establishes the optimal sampling probability measure to achieve the optimal rate of convergence. Various numerical examples are provided to validate the theoretical results.