freeCodeCamp/guide/chinese/certifications/javascript-algorithms-and-d.../regular-expressions/using-the-test-method/index.md

22 lines
548 B
Markdown
Raw Normal View History

---
title: Using the Test Method
localeTitle: 使用测试方法
---
## 使用测试方法
在这个挑战,你检查是否字符串包含一定的“正则表达式”,或**正则表达式** **REG** ular **前** pressions。您将使用`test()`方法来执行此操作。
## 提示1
在`myRegex`上调用测试方法。您认为这个论点是什么?
## 剧透警报 - 提前解决!
## 解
```javascript
let myString = "Hello, World!";
let myRegex = /Hello/;
let result = myRegex.test(myString); // Change this line
```