<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <script type="text/javascript"> /** * Example showing how to access each character of a string using the charAt() function. */ var sVeryLongString = "Hello, world!"; var sEachCharacters = ""; for(i=0; i<sVeryLongString.length; i++) { sEachCharacters += sVeryLongString.charAt(i)+"\n"; } window.alert(sEachCharacters); </script> <title>Access each charater of a string</title> </head> <body> </body> </html>
Output