<script type='text/javascript'> function changeChar(string, position, char) { return string.slice(0, position - 1) + char + string.slice(position); } alert( changeChar("Hello", 2, "j") ); </script>