Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Extract a Single Character from a String</title> </head> <body> <script> let str = "Hello World!"; document.write(str.charAt() + "<br>"); // Prints: H document.write(str.charAt(6) + "<br>"); // Prints: W document.write(str.charAt(30) + "<br>"); // Prints nothing document.write(str.charAt(str.length - 1)); // Prints: ! </script> </body> </html>