Code let pat = /cat/; // check for pattern using string search method document.writeln('Look for pattern using string search method'); if ("tomcat".search(pat) != -1) document.write("cat found in tomcat"); else document.write("cat not found in tomcat"); if ("tomboy".search(pat) != -1) document.write("cat found in tomboy"); else document.write("cat not found in tomboy"); // check for pattern using regular expression test method document.writeln('Look for pattern using regular expression test method'); if (pat.test("tomcat")) document.write("cat found in tomcat"); else document.write("cat not found in tomcat"); if (pat.test("tomboy")) document.write("cat found in tomboy"); else document.write("cat not found in tomboy");