Find One or More Criminals in a Hunt

Find One or More Criminals in a Hunt
0

#1

Tell us what’s happening:
Where is my wrong I can understand what to do with this code?
Your code so far


// example crowd gathering
let crowd = 'P1P2P3P4P5P6CCCP7P8P9';

let reCriminals = /CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC/; // Change this line

let matchedCriminals = crowd.match(reCriminals);
console.log(matchedCriminals);

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/find-one-or-more-criminals-in-a-hunt/


#2

What do you think this line is doing for your code?


#3

This ccccc… match with fifty criminals right?


#4

In my exercise tell me that :
Your regex should match fifty criminals (“CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC”) in “P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3”.

I have got three right and three wrong.


#5

// example crowd gathering
let crowd = ‘P1P2P3P4P5P6CCCP7P8P9’;

let reCriminals = /c+/gi; // Change this line

let matchedCriminals = crowd.match(reCriminals);
console.log(matchedCriminals);

That is right??


#6

You can test the code and find out.


#7

Ohh yes I try it and it is right.Thank you.


#8

So this can’t be right, i know i’m lazy but … hmmm
Your code so far


// example crowd gathering
let crowd = 'P1P2P3P4P5P6CCCP7P8P9';

let reCriminals = /C+/; // Change this line

let matchedCriminals = crowd.match(reCriminals);
console.log(matchedCriminals);

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/find-one-or-more-criminals-in-a-hunt