Advertisement
GamerBhai02

Program 10 Check substring

Nov 8th, 2024 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.58 KB | Source Code | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Substring Checker</title>
  5. </head>
  6. <body>
  7.     <script>
  8.         const str1 = "Hello, Enjoy your day.";
  9.         const str2 = "your";
  10.         document.write("str1 : "+str1);
  11.         document.write("<br>str2 : "+str2);
  12.         var inc = str1.includes(str2);
  13.         if(inc){
  14.             document.write("str2 is present in str1");
  15.         }else{
  16.             document.write("str2 is not present in str1");
  17.         }
  18.     </script>
  19.     <p>If it prints true then the main string consists of the substring else it doesnt.</p>
  20. </body>
  21. </html>
Tags: checksubstr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement