Tell us what’s happening:
let ohStr = "Ohhh no";
// let ohRegex = /^[a-gi-zA-GI-z]?h{3,6}\s/; // Change this line
let ohRegex = /^\w?h{3,6}\s/; // Change this line
let result = ohRegex.test(ohStr);
console.log(result);
My regex :
“let ohRegex = /^\w?h{3,6}\s/; // Change this line
”
or
“let ohRegex = /^[a-gi-zA-GI-z]?h{3,6}\s/; // Change this line
”
because this “/h{3,6}/
” fails all referenced criteria when “Run Test” is selected.
“let result = ohRegex.test(ohStr);
”
Section Question:
“Change the regex ohRegex to match the entire phrase Oh no only when it has
3 to
6 letter
h’s.
”
If I run a “console.log(result)
” on the below “ohStr”'s, these are the results:
let ohStr = "Ohh no"; // false
let ohStr = "Ohhh no"; // true
let ohStr = "Ohhhh no"; // true
let ohStr = "Ohhhhh no"; // true
let ohStr = "Ohhhhhh no"; // true
let ohStr = "Ohhhhhhh no"; // false
But the challenge requirements to pass is returning an “X” for below:
- Your regex should match the string
Ohhh no
- Your regex should match the string
Ohhhh no
- Your regex should match the string
Ohhhhh no
- Your regex should match the string
Ohhhhhh no
And a “Check Mark” for the below options:
- Your regex should use curly brackets.
- Your regex should not match the string
Ohh no
- Your regex should not match the string
Ohhhhhhh no
I basically gave up on another section because nothing seemed to work after a day and numerous YouTube videos and I am doing the same for this one because I am not understanding what is not work here.
When the example was " aaaah
" === /a{3,5}h/
returns true
.
Am I doing something wrong or could this possibly be a bug?
Any assistance would be greatly appreciated. Cheers!
Your code so far
let ohStr = "Ohhh no";
let ohRegex = /^[a-gi-zA-GI-z]?h{3,6}\s/; // Change this line
let result = ohRegex.test(ohStr);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Challenge: Specify Upper and Lower Number of Matches
Link to the challenge: