Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Find If a String Includes a Substring in JavaScript</title> </head> <body> <script> // Sample string var str = "The quick brown fox jumps over the lazy dog." // Check if string contains substring if(str.includes("fox")){ document.write("Substring found!"); } else{ document.write("Substring not found!"); } </script> </body> </html>