Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTimothy Haryadi
Full Stack JavaScript Techdegree Student 6,323 PointsStuck on "Regular Expression in Javascript": "The hexRegEx variable does not hold a regular expression object."
Hello, I'm currently on "Regular Expression in Javascript" and I'm stuck in a challenge task. I believe I got the regular expression correct but it's not accepting my code. Can some one take a look?
I've tried:
const hexRegEx = new RegExp(/^[#][a-z0-9]{6}$/gmi).test(text);
It works in the preview though.
Thanks!
1 Answer
Travis Alstrand
Treehouse Project ReviewerHey there Timothy Haryadi !
You're very close! This is what got to pass for me
const hexRegEx = /^#[a-f0-9]{6}$/i;
It wasn't until I removed the new RegEx()
code from the value I saw the error message change as it's just wanting the expression.
A very thorough explanation of this can be found here, I definitely recommend checking that out!
Timothy Haryadi
Full Stack JavaScript Techdegree Student 6,323 PointsTimothy Haryadi
Full Stack JavaScript Techdegree Student 6,323 PointsThat did it! Thanks Travis, it also turns out that I had
.test(text)
at the end. I was ahead of myself. Thetest()
part was supposed to be on the next step.