Time: 0:00
This is a logic errors bug
The wrong operator, an inverted condition, a formula the right way round but backwards.
return inside a forEach callback returns from the callback, not from hasNegative. forEach ignores whatever its callback returns and keeps going, then the outer function reaches return false. There is no way to stop a forEach early. Use a for...of loop, where return exits the whole function, or the method built for this question: nums.some((n) => n < 0). If a return seems to be ignored, check which function it actually belongs to.
The pattern behind it: logic errors.
Paste this into any web page or blog post. Visitors fix the bug right there, in their browser.
<iframe src="https://trybughunt.com/embed/38938071-d5a3-4e98-a5ff-66ee58bb332f" title="Debugging challenge: Validator never finds the negative number" width="100%" height="580" loading="lazy" style="border:1px solid #d4d4d8;border-radius:12px;max-width:760px"></iframe>
<p style="font-size:14px">Debugging challenge from <a href="https://trybughunt.com/challenges/38938071-d5a3-4e98-a5ff-66ee58bb332f">BugHunt</a></p>