1.9 KiB
1.9 KiB
id, title, challengeType, videoUrl, localeTitle
| id | title | challengeType | videoUrl | localeTitle |
|---|---|---|---|---|
| 587d7db3367417b2b2512b8e | Using the Test Method | 1 | Usando o método de teste |
Description
"the" na string "The dog chased the cat" , você pode usar a seguinte expressão regular: /the/ . Observe que as marcas de aspas não são necessárias na expressão regular. O JavaScript tem várias maneiras de usar regexes. Uma maneira de testar um regex é usando o método .test() . O método .test() pega o regex, aplica-o a uma string (que é colocada dentro dos parênteses) e retorna true ou false se o padrão encontrar algo ou não. deixe testStr = "freeCodeCamp";
deixe testRegex = / Code /;
testRegex.test (testStr);
// Retorna true
Instructions
myRegex na string myString usando o método .test() . Tests
tests:
- text: Você deve usar <code>.test()</code> para testar o regex.
testString: 'assert(code.match(/myRegex.test\(\s*myString\s*\)/), "You should use <code>.test()</code> to test the regex.");'
- text: Seu resultado deve retornar <code>true</code> .
testString: 'assert(result === true, "Your result should return <code>true</code>.");'
Challenge Seed
let myString = "Hello, World!";
let myRegex = /Hello/;
let result = myRegex; // Change this line
Solution
// solution required