Extract Matches help

Tell us what’s happening:

Your code so far


let extractStr = "Extract the word 'coding' from this string.";
let codingRegex = /coding/i; // Change this line
let result = extractStr; extractStr.match(codingRegex);// Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/extract-matches/
is this some kind of bug or I am doing something wrong?

1 Like

Challenge expects the match result be stored with variable result, so how do you put the result on result var?

I see your code copy the extractStr instead which is not correct.

You need to keep the return value of extractStr.match(codingRegex); to result. But your code doesn’t do that! it actually rejects the return value.


let result = extractStr.match(codingRegex);

If you still have issues, reveal the spoiler above, but try to fix it first yourself.

Keep going on great work, happy programming.

1 Like

With this “You need to keep the return value of extractStr.match(codingRegex); to result. But your code doesn’t do that! it actually rejects the return value.” I understood what stupid thing I did thanks man :slight_smile:

in this challenge it is a little bit difference from the previous challenges .

(.match( ) )in match extract we are going to apply the method on a string(will be inside the parentheses) and pass in the regex inside the parentheses

but (.test( ) ) takes the regex, applies it to a string (which is placed inside the parentheses)

in this link ,there is the best answer https://stackoverflow.com/questions/35308085/what-is-the-difference-between-match-and-test-in-javascript

1 Like

it’s ok man :sunglasses: