fix(curriculum):add code example for str.match() in step 35 of calorie counter project (#53461)

This commit is contained in:
Shaun_Sheep
2024-01-31 07:11:28 +01:00
committed by GitHub
parent 7e1a233a0c
commit 1863c70541

View File

@@ -6,8 +6,13 @@ dashedName: step-35
---
# --description--
Strings have a <dfn>.match()</dfn> method, which takes a regex argument. `.match()` will return an array of match results containing either the first match, or all matches if the global flag is used.
Strings have a `.match()` method, which takes a regex argument. `.match()` will return an array of match results containing either the first match, or all matches if the global flag is used.
```js
const str = 'example string';
const regex = /example/;
const result = str.match(regex); // Returns ['example']
```
Return the result of calling the `.match()` method on `str` and passing your `regex` variable as the argument. You'll use this match result later on.