From 1863c70541cf7cbc91c44ca641e49784f9d14608 Mon Sep 17 00:00:00 2001 From: Shaun_Sheep <54682807+GNUSheep@users.noreply.github.com> Date: Wed, 31 Jan 2024 07:11:28 +0100 Subject: [PATCH] fix(curriculum):add code example for str.match() in step 35 of calorie counter project (#53461) --- .../63bf5c438f523a359769106c.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63bf5c438f523a359769106c.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63bf5c438f523a359769106c.md index 5588fad6aaf..5dc5e5d1d18 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63bf5c438f523a359769106c.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63bf5c438f523a359769106c.md @@ -6,8 +6,13 @@ dashedName: step-35 --- # --description-- +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. -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.