Use charAt for browser compatibility.