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[0] + "<br>"); // Prints: H document.write(str[6] + "<br>"); // Prints: W document.write(str[str.length - 1] + "<br>"); // Prints: ! document.write(str[30]); // Prints: undefined </script> </body> </html>