Regular Expressions: Specify Upper and Lower Number of Matches vs Regular Expressions: Specify Only the Lower Number of Matches

Hello! I don’t understand why in this challenge
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches we do
let haStr = “Hazzzzah”;
let haRegex = /z{4,}/; // Change this line
let result = haRegex.test(haStr);
but here(https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/specify-upper-and-lower-number-of-matches/) we do
let ohStr = “Ohhh no”;
let ohRegex = /Oh{3,6}\sno/; // Change this line
let result = ohRegex.test(ohStr);
In hazzzah we need only z but in oh no we need to write also oh no :confused: why this? why not only h ? can someone explain it?

although this passes the first challenge you linked to, it is actually incorrect. The test cases are not showing you this but if the test cases had a test for not matching ‘zzzz’ this regex would have failed.

So the reason is simple, the test cases are different, and not necessarily fulfilling the original intention of the problem.

Thank you for the reply. So how should I write it correctly?

@hbar1st why is it incorrect.
question:
In hazzzah we need only z but in oh no we need to write also oh no :confused: why this? why not only h ? can someone explain it?
answer:
it is for the purpose of specifying the word where to find the match
try running this code:
let testOne = “Ohhh no match”;
let test = /Oh{3,6}\sno/; // Change this line
let answerOfTest = testOne.match(test);
console.log(answerOfTest);

you need to match also the starting ‘Ha’ and the ending ‘ah’

as I mentioned already in my response, you don’t only need z{4,}
This is a problem with the testcases as they don’t have a test for not matching ‘zzzz’.
I’m just repeating myself here, so I suggest you re-read my response.