Link Search Menu Expand Document

Using the Test Method

Summary

  • Regular expressions are used in programming languages to match parts of strings.
  • The .test() method takes the regex, applies it to a string (which is placed inside the parentheses), and returns true or false.

Final Code

let myString = "Hello, World!";
let myRegex = /Hello/;
let result = myRegex.test(myString); // Change this line